2 Replies Latest reply on May 16, 2003 4:29 AM by Matthias David

    how to pass username and password

    veshukla Newbie

      How to pass username and password from .NET to jboss.net web service?
      I am using Crediantials objects .
      But error I get as principal=null. It looks like
      the userid and password is not getting passed.
      Could some one help me with code snippets?
      Thanks,
      Regards,
      ~Veeru

        • 1. Re: how to pass username and password
          veshukla Newbie

          It works fine for Axis client
          But for VB.NET client
          I get following on TCPMonitor tool
          POST /jboss-net/services/MessageInput HTTP/1.1
          VsDebuggerCausalityData: AwAAANGVqp4GfsFCgN+XbOVBXTFQAE8AUgBTAEMASABFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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MS Web Services Client Protocol 1.0.3705.209)
          Content-Type: text/xml; charset=utf-8
          SOAPAction: "MessageInput"
          Content-Length: 1631
          Expect: 100-continue
          Connection: Keep-Alive
          Host: 209.157.27.153

          <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://209.157.27.153:100/jboss-net/services/MessageInput" xmlns:types="http://209.157.27.153:100/jboss-net/services/MessageInput/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><tns:messageInput><messageText xsi:type="xsd:string">What's up? How is it goin?<messageId xsi:type="xsd:string">11224<receivedTime xsi:type="xsd:dateTime">0001-01-01T00:00:00.0000000-08:00<processedTime xsi:type="xsd:dateTime">0001-01-01T00:00:00.0000000-08:00<nRetry xsi:type="xsd:int">1<timeElapsed xsi:type="xsd:long">0<messagePriority xsi:type="xsd:int">1<messageDestination xsi:type="xsd:string">5104323881<messageSource xsi:type="xsd:string">5104761730<protocolMessageId xsi:type="xsd:string" /><messageUserPriority xsi:type="xsd:int">0<dirty xsi:type="xsd:int">0<messageSourceProtocol xsi:type="xsd:string">NO_BO<messageDestinationProtocol xsi:type="xsd:string">SMPP<messageStatus xsi:type="xsd:int">0<protocolMessageStatus xsi:type="xsd:int">0<machineId xsi:type="xsd:string">honda<appId xsi:type="xsd:string" /></tns:messageInput></soap:Body></soap:Envelope>
          And get the error as:
          HTTP/1.1 500 Internal Server Error
          Date: Mon, 12 May 2003 18:26:56 GMT
          Server: Jetty/4.2.9 (Linux/2.4.18-3 i386 java/1.3.1_04)
          Content-Type: text/xml; charset=utf-8
          Transfer-Encoding: chunked

          18d8
          <?xml version="1.0" encoding="UTF-8"?>
          <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <soapenv:Body>
          <soapenv:Fault>
          <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Server.userException
          javax.ejb.EJBException: checkSecurityAssociation; CausedByException is:
          Authentication exception, principal=null

          <ns2:stackTrace xmlns:ns2="http://xml.apache.org/axis/">javax.ejb.EJBException: checkSecurityAssociation; CausedByException is:
          Authentication exception, principal=null
          at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityInterceptor.java:163)
          at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:81)
          at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
          at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
          at org.jboss.ejb.StatelessSessionContainer.internalInvokeHome(StatelessSessionContainer.java:310)
          at org.jboss.ejb.Container.invoke(Container.java:694)
          at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:272)
          at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
          at $Proxy59.create(Unknown Source)
          at java.lang.reflect.Method.invoke(Native Method)
          at org.jboss.net.axis.server.EJBProvider.makeNewServiceObject(EJBProvider.java:139)
          at org.apache.axis.providers.java.JavaProvider.getNewServiceObject(JavaProvider.java:206)
          at org.apache.axis.providers.java.JavaProvider.getServiceObject(JavaProvider.java:144)
          at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:258)
          at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
          at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:156)
          at org.apache.axis.SimpleChain.invoke(SimpleChain.java:126)
          at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:437)
          at org.apache.axis.server.AxisServer.invoke(AxisServer.java:316)
          at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:701)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
          at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:335)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
          at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)
          at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
          at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:558)
          at org.mortbay.http.HttpContext.handle(HttpContext.java:1714)
          at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:507)
          at org.mortbay.http.HttpContext.handle(HttpContext.java:1664)
          at org.mortbay.http.HttpServer.service(HttpServer.java:863)
          at org.jboss.jetty.Jetty.service(Jetty.java:460)
          at org.mortbay.http.HttpConnection.service(HttpConnection.java:775)
          at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:939)
          at org.mortbay.http.HttpConnection.handle(HttpConnection.java:792)
          at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:201)
          at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
          at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)
          java.lang.SecurityException: Authentication exception, principal=null
          at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityInterceptor.java:162)
          at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:81)
          at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
          at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
          at org.jboss.ejb.StatelessSessionContainer.internalInvokeHome(StatelessSessionContainer.java:310)
          at org.jboss.ejb.Container.invoke(Container.java:694)
          at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:272)
          at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
          at $Proxy59.create(Unknown Source)
          at java.lang.reflect.Method.invoke(Native Method)
          at org.jboss.net.axis.server.EJBProvider.makeNewServiceObject(EJBProvider.java:139)
          at org.apache.axis.providers.java.JavaProvider.getNewServiceObject(JavaProvider.java:206)
          at org.apache.axis.providers.java.JavaProvider.getServiceObject(JavaProvider.java:144)
          at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:258)
          at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
          at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:156)
          at org.apache.axis.SimpleChain.invoke(SimpleChain.java:126)
          at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:437)
          at org.apache.axis.server.AxisServer.invoke(AxisServer.java:316)
          at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:701)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
          at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:335)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
          at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)
          at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
          at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:558)
          at org.mortbay.http.HttpContext.handle(HttpContext.java:1714)
          at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:507)
          at org.mortbay.http.HttpContext.handle(HttpContext.java:1664)
          at org.mortbay.http.HttpServer.service(HttpServer.java:863)
          at org.jboss.jetty.Jetty.service(Jetty.java:460)
          at org.mortbay.http.HttpConnection.service(HttpConnection.java:775)
          at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:939)
          at org.mortbay.http.HttpConnection.handle(HttpConnection.java:792)
          at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:201)
          at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
          at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)
          </ns2:stackTrace>

          </soapenv:Fault>
          </soapenv:Body>
          </soapenv:Envelope>
          ..........
          I am using follwing code from VB.NET as follows:
          Dim oServices As MessageInputLocalService
          oServices = New MessageInputLocalService()
          'Dim tempCredentials As AuthHeader

          'tempCredentials = New AuthHeader()

          'tempCredentials.UserName = "shanu"
          'tempCredentials.Password = "shnau"

          Dim mycredentials As NetworkCredential = New NetworkCredential("shanu", "shanu")
          'oServices = New MessageInputLocalService()

          'oServices.theHeader = tempCredentials

          oServices.Credentials = mycredentials
          oServices.messageInput("What's up? How is it goin?", "11224", Nothing, Nothing, 1, 0, 1, "5104323881", _
          "5104761730", "", 0, 0, "NO_BO", _
          "SMPP", 0, 0, "honda", "")

          ..........................

          It looks like the username is getting passed.
          But in axis cleint I get as :
          POST /jboss-net/services/MessageInput HTTP/1.0
          Content-Type: text/xml; charset=utf-8
          Accept: application/soap+xml, application/dime, multipart/related, text/*
          User-Agent: Axis/1.0
          Host: 209.157.27.153
          Cache-Control: no-cache
          Pragma: no-cache
          SOAPAction: ""
          Content-Length: 1470
          Authorization: Basic c2hhbnU6c2hhbnU=

          <?xml version="1.0" encoding="UTF-8"?>
          <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <soapenv:Body>
          <messageInput soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <messageText xsi:type="xsd:string">What&apos;s up? How is it goin?
          <messageId xsi:type="xsd:string" xsi:nil="true"/>
          <receivedTime xsi:type="xsd:date" xsi:nil="true"/>
          <processedTime xsi:type="xsd:date" xsi:nil="true"/>
          <nRetry xsi:type="xsd:int">1
          <timeElapsed xsi:type="xsd:long">0
          <messagePriority xsi:type="xsd:int">1
          <messageDestination xsi:type="xsd:string">5104323881
          <messageSource xsi:type="xsd:string">5104761730
          <protocolMessageId xsi:type="xsd:string" xsi:nil="true"/>
          <messageUserPriority xsi:type="xsd:int">0
          <dirty xsi:type="xsd:int">0
          <messageSourceProtocol xsi:type="xsd:string">NO_BO
          <messageDestinationProtocol xsi:type="xsd:string">SMPP
          <messageStatus xsi:type="xsd:int">0
          <protocolMessageStatus xsi:type="xsd:int">0
          <machineId xsi:type="xsd:string" xsi:nil="true"/>
          <appId xsi:type="xsd:string" xsi:nil="true"/>

          </soapenv:Body>
          </soapenv:Envelope>
          For axis I used
          call.setProperty(Call.USERNAME_PROPERTY,"user");
          call.setProperty(Call.PASSWORD_PROPERTY,"pass");
          and It works for axis cleint but not for VB.NET cleint
          . Where is the problem? any idea?
          Regards,
          ~Veeru

          • 2. Re: how to pass username and password
            Matthias David Newbie

            Well, I haven't developed with .NET yet, but you may try to set the URL for your WebService as follows:

            "username:password@http://yourUrl:port/service"

            This works with Axis Clients instead of using the setter methods for username and password. Should work with .NET , too.

            Matthias.