You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Reinout van Schouwen <re...@gmail.com> on 2008/02/13 15:28:02 UTC

newbie question

Hello all,

I'm new to this list so if my question is anwered elsewhere and I didn't
find it in the archive, my apologies.

I have to make some simple calls to a webservice hosted on an IIS
server. A valid "Login" call should look like this, according to the
spec:

POST /webservices/ExternalRedirectionService.asmx HTTP/1.1
Host: gww-ob.nl
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://[someurl.tld]/WebServices/Login"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Login xmlns="http://[someurl.tld]/WebServices/">
      <username>string</username>
      <password>string</password>
    </Login>
  </soap:Body>
</soap:Envelope>

I wrote this code after studying the tutorial (the localhost:8888 is for
tcpmon, which forwards to the actual server on port 80):

   import org.apache.axis.client.Call;
   import org.apache.axis.client.Service;
   import javax.xml.namespace.QName;
   
   public class TestClient {
      public static void main(String [] args) {
          try {
              String endpoint =
                       "http://localhost:8888/webservices/ExternalRedirectionService.asmx";
  
             Service  service = new Service();
             Call     call    = (Call) service.createCall();
             call.setTargetEndpointAddress( new java.net.URL(endpoint) );
	     call.setSOAPActionURI("http://[myurl.tld]/WebServices/Login");

             call.addParameter("username", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
             call.addParameter("password", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
             
             call.setReturnType(org.apache.axis.Constants.XSD_STRING);
              
             String ret = (String) call.invoke(new QName("http://[myurl.tld]/WebServices/", "Login"), new Object[] { "[username]", "[password]" } );
  
             System.out.println("Got '" + ret + "'");
         } catch (Exception e) {
             System.err.println(e.toString());
         }
    }
  }

This yields the following call:

POST /webservices/ExternalRedirectionService.asmx HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.2alpha
Host: [someurl.tld]:8888
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "http://www.[someurl.tld]/WebServices/Login"
Content-Length: 520

<?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>
  <ns1:Login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.[someurl.tld]/WebServices/">
   <username xsi:type="xsd:string">[username]</username>
   <password xsi:type="xsd:string">[password]</password>
  </ns1:Login>
 </soapenv:Body>
</soapenv:Envelope>

(I know I'm using an old version of Axis, that's a constraint I have to work with.)

The webserver then replies with:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Csla.DataPortalException: DataPortal.Fetch failed ---> Csla.Server.CallMethodException: DataPortal_Fetch method call failed ---> System.Data.SqlClient.SqlException: Procedure 'security_login' expects parameter '@st_username', which was not supplied.

followed by a long stack trace.

My question is, naturally: what am I doing wrong here?

Thanks for any insights.

regards,

-- 
Reinout van Schouwen
http://vanschouwen.info/


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


adding custom header to request

Posted by Reinout van Schouwen <re...@gmail.com>.
Hello Anne,

Op zondag 17-02-2008 om 14:20 uur [tijdzone -0500], schreef Anne Thomas
Manes:
> Do you have a WSDL that goes with the service? You can use WSDL2java
> to generate a client proxy for you. That will make things easier for
> you.

Yes. In the mean time I have generated a client proxy. I have narrowed
down my problem to the following: the (.NET) web service returns a
custom SOAP header called 'TicketHeader' which it expects to be returned
to it, as a SOAP header, on subsequent client requests. It appears that
proxy classes generated on .NET retain this custom header automatically
whereas Axis-generated proxy classes do not.

My first approach to solve this was to try and get the SOAP request
message from the call's messagecontext in the proxy classes, in order to
insert the header manually. However, I found out that the request
message is generated only after the call is invoked. So, my second
approach was to register a custom handler on the client side that
inserts the TicketHeader header upon invoke(). 
Unfortunately, although I can verify that I added my custom handler to
the handler chain in the service's handler registry by calling
super.service.getHandlerRegistry().getHandlerChain(), it is never
invoked. I wonder what what be the cause for this. Any suggestions on
how to debug it?

regards,

-- 
Reinout van Schouwen



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: newbie question

Posted by Anne Thomas Manes <at...@gmail.com>.
Do you have a WSDL that goes with the service? You can use WSDL2java
to generate a client proxy for you. That will make things easier for
you.

I'm not sure you can use the DII call interface to invoke this
service. The service is a document/literal service, and the call
interface is designed to work with RPC services. The call interface
automatically generates unqualified accessor elements for the
parameter types (i.e., the username and password elements). But your
service requires that these elements be qualified. I have never
figured out how to get the call.addParameter method to product a
qualified element.

Anne

On Feb 13, 2008 9:28 AM, Reinout van Schouwen <re...@gmail.com> wrote:
> Hello all,
>
> I'm new to this list so if my question is anwered elsewhere and I didn't
> find it in the archive, my apologies.
>
> I have to make some simple calls to a webservice hosted on an IIS
> server. A valid "Login" call should look like this, according to the
> spec:
>
> POST /webservices/ExternalRedirectionService.asmx HTTP/1.1
> Host: gww-ob.nl
> Content-Type: text/xml; charset=utf-8
> Content-Length: length
> SOAPAction: "http://[someurl.tld]/WebServices/Login"
>
> <?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>   <soap:Body>
>     <Login xmlns="http://[someurl.tld]/WebServices/">
>       <username>string</username>
>       <password>string</password>
>     </Login>
>   </soap:Body>
> </soap:Envelope>
>
> I wrote this code after studying the tutorial (the localhost:8888 is for
> tcpmon, which forwards to the actual server on port 80):
>
>    import org.apache.axis.client.Call;
>    import org.apache.axis.client.Service;
>    import javax.xml.namespace.QName;
>
>    public class TestClient {
>       public static void main(String [] args) {
>           try {
>               String endpoint =
>                        "http://localhost:8888/webservices/ExternalRedirectionService.asmx";
>
>              Service  service = new Service();
>              Call     call    = (Call) service.createCall();
>              call.setTargetEndpointAddress( new java.net.URL(endpoint) );
>              call.setSOAPActionURI("http://[myurl.tld]/WebServices/Login");
>
>              call.addParameter("username", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
>              call.addParameter("password", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
>
>              call.setReturnType(org.apache.axis.Constants.XSD_STRING);
>
>              String ret = (String) call.invoke(new QName("http://[myurl.tld]/WebServices/", "Login"), new Object[] { "[username]", "[password]" } );
>
>              System.out.println("Got '" + ret + "'");
>          } catch (Exception e) {
>              System.err.println(e.toString());
>          }
>     }
>   }
>
> This yields the following call:
>
> POST /webservices/ExternalRedirectionService.asmx HTTP/1.0
> Content-Type: text/xml; charset=utf-8
> Accept: application/soap+xml, application/dime, multipart/related, text/*
> User-Agent: Axis/1.2alpha
> Host: [someurl.tld]:8888
> Cache-Control: no-cache
> Pragma: no-cache
> SOAPAction: "http://www.[someurl.tld]/WebServices/Login"
> Content-Length: 520
>
> <?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>
>   <ns1:Login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.[someurl.tld]/WebServices/">
>    <username xsi:type="xsd:string">[username]</username>
>    <password xsi:type="xsd:string">[password]</password>
>   </ns1:Login>
>  </soapenv:Body>
> </soapenv:Envelope>
>
> (I know I'm using an old version of Axis, that's a constraint I have to work with.)
>
> The webserver then replies with:
>
> System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Csla.DataPortalException: DataPortal.Fetch failed ---> Csla.Server.CallMethodException: DataPortal_Fetch method call failed ---> System.Data.SqlClient.SqlException: Procedure 'security_login' expects parameter '@st_username', which was not supplied.
>
> followed by a long stack trace.
>
> My question is, naturally: what am I doing wrong here?
>
> Thanks for any insights.
>
> regards,
>
> --
> Reinout van Schouwen
> http://vanschouwen.info/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org