users@jax-rpc.java.net

Re: Communication problem between Apache-Axis WebService and JWSDP client

From: Narinder Kumar <nkumarfr_at_aol.com>
Date: Mon, 5 Jul 2004 14:41:38 +0200
Hi All,

I did not get any response about my earlier query, so resending again. Plus I have some related questions which are at the end of this mail.

Regards
Narinder

Narinder Kumar wrote on 02/07/2004, 15:50:

Hi

I am trying to implement a JAX-RPC client for a Web Service implemented using Apache-Axis running on Tomcat 4.1.

I am implementing static stub client and used wscompile (JWSDP 1.3) for generating stubs. The instantiation of stub passes normally but while calling a method on WebService it throws an exception saying :

        deserialization error: deserialization error: unexpected XML reader state. expected:
 END but found: START: country
java.rmi.RemoteException: Runtime exception; nested exception is:
        deserialization error: deserialization error: unexpected XML reader state. expected:
 END but found: START: country
        at com.sun.xml.rpc.client.StreamingSender._handleRuntimeExceptionInSend(StreamingSen
der.java:248)
        at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:230)
        at com.aol.tamagochi.webservice.FadFogwService_Stub.preQualify(FadFogwService_Stub.j
ava:68)
        at FogWSDynClient.main(FogWSDynClient.java:50)
Caused by: deserialization error: deserialization error: unexpected XML reader state. expect
ed: END but found: START: country
        at com.sun.xml.rpc.encoding.SOAPDeserializationContext.deserializeMultiRefObjects(SO
APDeserializationContext.java:82)
        at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:163)
        ... 2 more

Some more details about Web Service method : Both input parameter and return type are user defined complex types, which are implemented as Java Beans. What can be the reasons, Are there any compatibility issues between Apache-Axis and JWSDP ?

I did search on the forum and found there were some issues related to complex types. Someone had suggested to generate stubs using "-f:searchschema" option but that also does not help in my case.

Regards
Narinder

In the mean time I used the standard Dynamic Client procedure (which is not implementation specific) and tried to access Apache-Axis WebService, and it works fine for me. Does that confirm my doubt that Static Stub Client code like the one below is going to work only for SUN-JWSDP WebService and its clients and thus should be avoided when communicating between different web service implementations :

    private static Stub createProxy() throws Exception {
        try {
           return (Stub) (new MyWebService_Impl().getMyWebServiceIFPort());
        } catch (Exception ex) {
            throw new Exception (ex.toString());
        }
    }

That raises another question related to Security/Authentication between WebService/Client :

In my webservice implemented using JWSDP-1.3, I use Tomcat BASIC Authentication mechanism in web.xml specifying a username/password :

  <security-constraint>
    <web-resource-collection>
      <web-resource-name>PeemsWebService</web-resource-name>
      <url-pattern>/PeemsWS</url-pattern>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
      <role-name>peemsadmins</role-name>
    </auth-constraint>   
    <user-data-constraint>
      <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
  </security-constraint>

When using Static client (implementation specific), we can set the properties for username/password by doing :

            Stub stub = (Stub) (new
MyWebService_Impl().getMyWebServiceIFPort());
            stub._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY, "peemsadmin");
            stub._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, "peemsadmin");
            stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
            myPeems = (PeemsIF) stub;

But when we follow the standard procedure of creating a service proxy (Dynamic Client) through ServiceFactory, we get HTTP 401 exception :

        static String endpointAddress = "http://localhost:8080/peemswebservice/PeemsWS";
        static String UrlString = "http://localhost:8080/peemswebservice/PeemsWS?WSDL";
        static String nameSpaceUri = "urn:Foo";
        static String serviceName = "PeemsWebService";
        static String portName = "PeemsIFPort";
        URL peemsWSDLUrl = new URL(UrlString);
        PeemsIF myProxy = null;
        ServiceFactory serviceFactory = ServiceFactory.newInstance();

        Service peemsWService = serviceFactory.createService
                                (peemsWSDLUrl, new QName(nameSpaceUri, serviceName));


Exception :      [java] modeler error: failed to parse document at "http://localhost:8080/peemswebservic
e/PeemsWS?WSDL": java.io.IOException: Server returned HTTP response code: 401 for URL: http:
//localhost:8080/peemswebservice/PeemsWS?WSDL

My question is : How should we set
javax.xml.rpc.Stub.USERNAME_PROPERTY and javax.xml.rpc.Stub.PASSWORD_PROPERTY while using Dynamic proxy client procedure ?

Regards
Narinder
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@jax-rpc.dev.java.net For additional commands, e-mail: users-help@jax-rpc.dev.java.net