Announcement Announcement Module
Collapse
No announcement yet.
Getting unexpected encoding when calling RPC/encoded style webservice using Springws Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting unexpected encoding when calling RPC/encoded style webservice using Springws

    Hi,

    I am trying to consume a RPC/encoded style webservice using SPring ws client ie. webservicetemplate. I dont have any information of this webservice other than wsdl. But i am not able to figure out how to form the request xml.

    Below is the code and exception i am getting:

    Request.xml:
    <?xml version="1.0" encoding="utf-8"?>
    <ldap:authenticate xmlns:ldap="http://www.wsso.abc.com/LDAPAuth">
    <ldap:String_1>1234</ldap:String_1>
    <ldap:String_2>abc</ldap:String_2>
    <ldap:String_3>ALL</ldap:String_3>
    </ldap:authenticate>

    This i framed based on following soapUI request which is currently retrieving correct response.

    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ldap="http://www.wsso.abc.com/LDAPAuth">
    <soapenv:Header/>
    <soapenv:Body>
    <ldap:authenticate soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <String_1 xsi:type="xsd:string">username</String_1>
    <String_2 xsi:type="xsd:string">password</String_2>
    <String_3 xsi:type="xsd:string">ALL</String_3>
    </ldap:authenticate>
    </soapenv:Body>
    </soapenv:Envelope>

    if username and password are replaced by exact values.

    Here is the SoapResponse:
    <env:Envelope env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://www.wsso.abc.com/type/LDAPAuth">
    <env:Body>
    <ans1:authenticateResponse xmlns:ans1="http://www.wsso.abc.com/LDAPAuth">
    <result xsi:type="xsd:string">0:Contractors</result>
    </ans1:authenticateResponse>
    </env:Body>
    </env:Envelope>

    This is my client.java:

    public class Client extends WebServiceGatewaySupport{

    public void run() throws JAXBException {
    try {
    StreamSource src = new StreamSource(new FileInputStream("src/request.xml"));
    StreamResult res = new StreamResult(System.out);
    getWebServiceTemplate().sendSourceAndReceiveToResu lt(src, res);

    } catch (Exception e) {
    e.printStackTrace();
    }

    }

    /**
    * @param args
    */
    public static void main(String[] args) throws JAXBException{
    ApplicationContext app = new ClassPathXmlApplicationContext(
    new String[] { "appContext.xml" });
    Client c = (Client) app
    .getBean("pseudoClient");
    c.run();
    }

    }


    Here is the output:
    org.springframework.ws.soap.client.SoapFaultClient Exception: JAXRPCTIE01: caught exception while handling request: unexpected encoding style: expected=http://schemas.xmlsoap.org/soap/encoding/, actual=
    at org.springframework.ws.soap.client.core.SoapFaultM essageResolver.resolveFault(SoapFaultMessageResolv er.java:37)
    at org.springframework.ws.client.core.WebServiceTempl ate.handleFault(WebServiceTemplate.java:738)
    at org.springframework.ws.client.core.WebServiceTempl ate.doSendAndReceive(WebServiceTemplate.java:564)
    at org.springframework.ws.client.core.WebServiceTempl ate.sendAndReceive(WebServiceTemplate.java:502)
    at org.springframework.ws.client.core.WebServiceTempl ate.doSendAndReceive(WebServiceTemplate.java:457)
    at org.springframework.ws.client.core.WebServiceTempl ate.sendSourceAndReceiveToResult(WebServiceTemplat e.java:403)
    at org.springframework.ws.client.core.WebServiceTempl ate.sendSourceAndReceiveToResult(WebServiceTemplat e.java:394)
    at com.fedex.infosec.client.InfosecClient.run(Infosec Client.java:75)
    at com.fedex.infosec.client.InfosecClient.main(Infose cClient.java:98)


    When i include a clientInterceptor and try to print SoapMessage in HandleRequest() method if prints...soapmessage as
    soap mesg req--SaajSoapMessage {http://www.wsso.abc.com/LDAPAuth}authenticate. Its not bounded with Soap envelope elements as expected. Also it is looking at some kind of encoding style needs to be sent as part of my request.

    Please let me know how to send correct request xml.

    Any kind of help is much appreciated.

    Thanks
    Pallavi.

  • #2
    Hi

    Been there, done that. Spring-WS uses marshalling libraries (e.g. JAXB2) to create requests and unmarshall responses. RPC/Encoded is deprecated (according to WS-I) style of web services implemented by old JAX-RPC compliant libraries (e.g. Axis1, Sun's JAX-RPC RI).

    I've tried to rip unmarshalling code from Axis (BeanDeserializers), but there were many problems. So without much changes to Spring-WS you should use Axis 1.4...

    regards
    Grzegorz Grzybek

    Comment


    • #3
      Thanks

      Hi Grzegorz,

      Thanks for the response. Yes i was successful in generating client using JAX-RPC. But our requirement is to reimplement this using Spring-ws. Now i am much clear with your answer.

      Comment


      • #4
        HI

        I finally could create a Spring client using Axis and JAXRPC.

        Here is my appcontext.xml.

        <bean id="ldapService" class="org.springframework.remoting.jaxrpc.JaxRpcP ortProxyFactoryBean">

        <property name="serviceFactoryClass">
        <value>org.apache.axis.client.ServiceFactory</value>
        </property>

        <property name="wsdlDocumentUrl">
        <value>https://abc.com/LDAPAuth/LDAPAuth?WSDL</value>
        </property>

        <property name="namespaceUri">
        <value>http://www.wsso.abc.com/LDAPAuth</value>
        </property>

        <property name="serviceName">
        <value>LDAPAuth</value>
        </property>

        <property name="portName">
        <value>LDAPAuthPort</value>
        </property>

        <property name="portInterface">
        <value>com.abc.wsclients.LDAPAuthRemote</value>
        </property>

        <property name="serviceInterface">
        <value>com.abc.wsclients.LDAPAuthService</value>
        </property>

        </bean>

        This worked fine on Tomcat. Again i am facing pb when it is deployed on JBOSS.
        I am getting below stack trace on JBOSS:

        SEVERE: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.apache.axis.message.MessageElement.getChildEl ements(Ljavax/xml/namespace/QNameLjava/util/Iterator;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, org/apache/axis/message/MessageElement, and the class loader (instance of <bootloader>) for interface javax/xml/soap/SOAPElement have different Class objects for the type javax/xml/namespace/QName used in the signature
        at org.apache.axis.client.Call.invoke(Call.java:2364)
        at org.apache.axis.client.Call.invoke(Call.java:1812)
        at org.apache.axis.client.AxisClientProxy.invoke(Axis ClientProxy.java:163)
        at $Proxy118.authenticate(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.remoting.rmi.RmiClientIntercep torUtils.invokeRemoteMethod(RmiClientInterceptorUt ils.java:113)
        at org.springframework.remoting.jaxrpc.JaxRpcPortClie ntInterceptor.doInvoke(JaxRpcPortClientInterceptor .java:617)
        at org.springframework.remoting.jaxrpc.JaxRpcPortClie ntInterceptor.doInvoke(JaxRpcPortClientInterceptor .java:584)
        at org.springframework.remoting.jaxrpc.JaxRpcPortClie ntInterceptor.invoke(JaxRpcPortClientInterceptor.j ava:562)
        at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
        at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy119.authenticate(Unknown Source)

        As i need my client to be deployed on JBOSS as our application needs to be running on JBOSS. Please help me resolving above conflict.

        Appreciate your help.

        Thanks
        Pallavi.

        Comment


        • #5
          Resolved

          It was just some JBOSS jars conflicting with jaxrpc.jar i included in web-inf/lib.
          Deleting this solved the issue.

          Comment

          Working...
          X