Announcement Announcement Module
Collapse
No announcement yet.
javax.xml.rpc.handler to work with Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • javax.xml.rpc.handler to work with Spring

    Hi

    I need to do some programatic processing before a SOAP message is sent and thus I use javax.xml.rpc.handler.GenericHandler.

    My code works fine if I do not use any Spring related Remoting support = using plain Axis generated code based on a .wsdl file.

    However if I use org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean

    my handler is never invoked even though I register the handler excatly the same way as I will do it with pure Axis code.

    I am pasting some snipets here:

    Spring.xml
    Code:
    	<bean id="ediWS" class="dk.webfragt.access.edi.EDIWebServiceFactory">
    		<property name="serviceInterface">
    			<value>dk.webfragt.access.edi.Version</value>
    		</property>
    		<property name="wsdlDocumentUrl">
    			<value>http&#58;//localhost&#58;8181/axis/services/Version?wsdl</value>
    		</property>
    		<property name="namespaceUri">
    			<value>http&#58;//localhost&#58;8181/axis/services/Version</value>
    		</property>
    		<property name="serviceName">
    			<value>VersionService</value>
    		</property>
    		<property name="portName">
    			<value>Version</value>
    		</property>
    	</bean>


    And my factory that registers my handler in the postProcessJaxRpcService.

    Code:
    public class EDIWebServiceFactory extends JaxRpcPortProxyFactoryBean &#123;
    
    	protected void postProcessJaxRpcService&#40;Service service&#41; &#123;
    		logger.debug&#40;"XXX Setting Handler on Port - START"&#41;;
    		List list = service.getHandlerRegistry&#40;&#41;.getHandlerChain&#40;new QName&#40;"Version"&#41;&#41;;
    		list.add&#40;new HandlerInfo&#40;EDIHeaderHandler.class, null, null&#41;&#41;;
    		logger.debug&#40;"XXX Setting Handler on Port - DONE"&#41;;
    	&#125;
    
    &#125;

    When I do this my handler is never invoked and thus the SOAP message can't be modified in my handler before sending it to the remote server. If I use pure Axis my handler is invoked.


    If I use this pure Axis code it works
    Code:
    		logger.debug&#40;"Getting EDI JAX-RPC service at " + url&#41;;
    		ECBroker2Locator loc = new ECBroker2Locator&#40;&#41;; 
    		broker = loc.geteCBrokerIFPort&#40;new URL&#40;url&#41;&#41;;
    		logger.debug&#40;"Got EDI JAX-RPC service"&#41;;
    		
    		logger.debug&#40;"Setting Handler on Port - START"&#41;;
    		Service jax = &#40;Service&#41; loc;
    		List list = jax.getHandlerRegistry&#40;&#41;.getHandlerChain&#40;new QName&#40;"eCBrokerIFPort"&#41;&#41;;
    		list.add&#40;new HandlerInfo&#40;EDIHeaderHandler.class, null, null&#41;&#41;;
    		logger.debug&#40;"Setting Handler on Port - DONE"&#41;;
    	&#125;
    Where the code ECBroker2Locator is auto generated by Axis.[/code]



    And from my tomcat log
    Code:
    main 10 jan 2005 14&#58;36&#58;02 DEBUG dk.webfragt.access.edi.EDIWebServiceFactory - Creating JAX-RPC service &#91;VersionService&#93;
    main 10 jan 2005 14&#58;36&#58;03 INFO  dk.webfragt.access.edi.EDIWebServiceFactory - JAX-RPC service &#91;VersionService&#93; created
    main 10 jan 2005 14&#58;36&#58;03 DEBUG dk.webfragt.access.edi.EDIWebServiceFactory - XXX Setting Handler on Port - START +++
    main 10 jan 2005 14&#58;36&#58;04 DEBUG dk.webfragt.access.edi.EDIWebServiceFactory - XXX Setting Handler on Port - DONE
    main 10 jan 2005 14&#58;36&#58;04 INFO  dk.webfragt.access.edi.EDIWebServiceFactory - Using service interface &#91;dk.webfragt.access.edi.Version&#93; for JAX-RPC object &#91;&#123;http&#58;//localhost&#58;8181/axis/services/Version&#125;Version&#93; -  directly implemented
    main 10 jan 2005 14&#58;36&#58;04 DEBUG dk.webfragt.access.edi.EDIDao - Setting service
    The JAX-RPC service is created fine and the handler is registered (I hope so because I do not get any exceptions)

    And when I run the webservice I get the response from the remote server
    Code:
    http8080-Processor4 10 jan 2005 14&#58;36&#58;18 DEBUG dk.webfragt.access.edi.EDIDao - Getting version +++
    return from WS&#58; Apache Axis version&#58; 1.1
    Built on Jun 13, 2003 &#40;09&#58;19&#58;43 EDT&#41;
    But my handler is never invoked - I have a System.out call and a logger output too but nothing in the tomcat log. I also checked with DEBUG level for apache.axis but the SOAP message did not contain my modifications.

  • #2
    it works

    Okay

    I started digging into the problem. Setup IDEA to remote debug Tomcat and added Axis source files so I could see what is going on.

    I discovered that Axis was expecting the QName to be including the namespaceURI.

    So instead of just "Version" it should be "{http://localhost:8181/axis/services/Version}/Version"

    So when I changed my code to:

    Code:
    public class EDIWebServiceFactory extends JaxRpcPortProxyFactoryBean &#123;
    
    	protected void postProcessJaxRpcService&#40;Service service&#41; &#123;
            QName port = new QName&#40;this.getNamespaceUri&#40;&#41;, this.getPortName&#40;&#41;&#41;;
    		List list = service.getHandlerRegistry&#40;&#41;.getHandlerChain&#40;port&#41;;
    		list.add&#40;new HandlerInfo&#40;EDIHeaderHandler.class, null, null&#41;&#41;;
    
    		logger.info&#40;"Registered JAX-RPC Handler &#91;" + EDIHeaderHandler.class.getName&#40;&#41; + "&#93; on port " + port&#41;;
    	&#125;
    
    &#125;
    It worked nicely.

    Comment

    Working...
    X