Announcement Announcement Module
Collapse
No announcement yet.
Spring WS and rpc/encoded style messages? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring WS and rpc/encoded style messages?

    Hello,

    we need to connect two systems (an old one, and a new one based upon Spring Core and Spring WS). There is already a WSDL description for a WebService, provided by the old system. The style is "rpc/encoded".

    I read in the Spring WS reference, that "rpc/encoded" is deprecated.

    Is Spring WS nevertheless able to handle "rpc/encoded" style SOAP messages (handle as a client, and as a WebService-Server)?


    Thanks a lot for your help

    Regards

  • #2
    Yes it can. Spring-WS doesn't support rpc/encoded style but it allows you to put virtually any valid XML into your messages.
    It actually depends on how you're going to process the XML. On the server side, just ignore the encoding attributes when you read you message.
    For example, you can use XPath to map XML values to your parameters.
    On the client side, if the the encoding attributes are required by the server, you'll have to add them yourself.

    Comment


    • #3
      Hello tareq,

      thanks a lot for your answer. This is great news, I really looking forward to learning/using Spring WS.

      Comment


      • #4
        Hi

        I've went through the same issues - connecting (as a client) from Spring-Integration to RPC/Encoded Axis1 service.

        First I've tried to generate JAXB2 classes from WSDL (with soap-encoding) to have an object model I can operate on - JAXB2 generated classes for the entities defined in http://schemas.xmlsoap.org/soap/encoding/ namespace and I thought that it would be easy to extract BeanSerializers from Axis1 to do marshalling... But the resulting XML was not what I expected.

        After some hacking, my solution looked like this:

        1) classes are generated with Axis1's wsdl2java (with all these scary-looking static blocks)

        2) there is client-config.wsdd which contains:
        Code:
        <?xml version="1.0" encoding="utf-8"?>
        
        <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xml.apache.org/axis/wsdd/ file://C:/java/_schema/wsdd.xsd">
        
           <globalConfiguration>
              <requestFlow>
                 <handler type="java:xyz.integration.interceptors.Axis1HandlerAdapter" />
              </requestFlow>
              <responseFlow>
                 <handler type="java:xyz.integration.interceptors.Axis1HandlerAdapter" />
              </responseFlow>
           </globalConfiguration>
        
           <transport name="http" pivot="java:xyz.senders.Axis1HTTPSender" />
        
        </deployment>
        3) Axis1HandlerAdapter is a class implementing Axis1's BasicHandler and containing Spring's ClientInterceptor's array.
        4) There's a FactoryBean which produces Axis'1 interface to rpc/encoding service after some tweaks to these handlers and to the sender:
        Code:
           @Override
           public IWS getObject() throws Exception
           {
              ServiceLocator locator = new ServiceLocator();
              
              // Axis1 handler - we're giving it access to SpringFramework
              Axis1HandlerAdapter requestAdapter = (Axis1HandlerAdapter)((SimpleChain)locator.getEngine().getGlobalRequest()).getHandlers()[0];
              Axis1HandlerAdapter responseAdapter = (Axis1HandlerAdapter)((SimpleChain)locator.getEngine().getGlobalResponse()).getHandlers()[0];
        
              DomPoxMessageFactory messageFactory = new DomPoxMessageFactory();
              requestAdapter.setMessageFactory(messageFactory);
              requestAdapter.setInterceptors(this.interceptors);
              responseAdapter.setMessageFactory(messageFactory);
              responseAdapter.setInterceptors(this.interceptors);
              
              Axis1HTTPSender sender = (Axis1HTTPSender)((SimpleTargetedChain)locator.getEngine().getTransport("http")).getPivotHandler();
              if (this.useSslAuth)
                 sender.setSocketFactory(new AuthAxis1SocketFactory(this.keystore, this.keystorePassword, this.keystoreType, this.truststore, this.truststorePassword, this.truststoreType));
        
              IWS remoteRpcEncodedService = locator.getservice(new URL(this.address));
              ((Stub)remoteRpcEncodedService ).setUsername(this.username);
              ((Stub)remoteRpcEncodedService ).setPassword(this.password);
              ((Stub)remoteRpcEncodedService ).setTimeout(this.timeout);
              
              return remoteRpcEncodedService;
           }
        5) Axis1's sender has Spring configured org.apache.axis.components.net.SocketFactory which then uses CommonsHttpClient SecureProtocolSocketFactory implementation (one of the extra implementations from src\contrib\org\apache\commons\httpclient\contrib\ ssl directory) to create sockets.
        6) Finally I invoke the rpc/encoded service using standard stubs generated by Axis1, but I have all the benefits of both spring configuration and spring ClientInterceptor (the same I use for WebServicesTemplate) objects.

        My conclusion is that there are too many problems with trying to use JAXB2 classes (great for document style XMLs) with http://schemas.xmlsoap.org/soap/encoding/ namespace + Axis1's BeanSerializer (which can handle marshalling with SOAP encoding) is not as easily "embeddable" as a marshalling engine as it should be.

        with best regards
        Grzegorz Grzybek

        Comment

        Working...
        X