Announcement Announcement Module
Collapse
No announcement yet.
Spring-ws processing messages with no Soap Header tag Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring-ws processing messages with no Soap Header tag

    I have been re-writing an existing webservice with Spring-ws to take advantage of maven for dependency management and profiling the build process. I also updated the project from outdated xfire jars to using spring-ws.

    The current production webservice passes a Soap request like this
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    	<soap:Body>
    		<getTaxID xmlns="http://acdt1403:8080/CustKeyService">
    			<id>some string</id>
    		</getTaxID>
    	</soap:Body>
    </soap:Envelope>
    And the response is returned like this

    Code:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    	xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    	<soap:Body>
    		<getTaxIDResponse xmlns="http://acdt1403:8080/CustKeyService">
    			<out>some value</out>
    		</getTaxIDResponse>
    	</soap:Body>
    </soap:Envelope>
    Notice there is no <soap:Header /> element. From what I've seen this is not required. When I use the contract first approach to recreate the existing wsdl, it seems to create the same wsdl used for consumption today. However, when Spring-ws processes this it throws a fault because the soap-header is null.

    I can get into the appropriate methods, but it looks like I've only triggered a race condition because about half way through the method it throws a null pointer exception when trying to process the soap message. The following error is returned to the web service client
    Error getting tax id: exception = System.Web.Services.Protocols.SoapHeaderException: java.lang.NullPointerException
    at System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
    Has anyone dealt with this or does anyone have a suggestion around it?

    Here's the webservice pieces
    webXML
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
    
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/root-context.xml</param-value>
      </context-param>
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
    
      <display-name>SPIService</display-name>
      <servlet>
        <servlet-name>spring-ws</servlet-name>
        <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
        <init-param>
          <param-name>transformWsdlLocations</param-name>
          <param-value>true</param-value>
        </init-param>
        <init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/spring/spring-ws-servlet.xml</param-value>
        </init-param>
      </servlet>
      <servlet-mapping>
        <servlet-name>spring-ws</servlet-name>
        <url-pattern>/*</url-pattern>
      </servlet-mapping>
      
    
      <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/views/</url-pattern>
      </servlet-mapping>
    spring-ws-servlet
    Code:
    	<sws:annotation-driven/>
    	<context:component-scan base-package="com.americancentury.custdataservice" />
    	<sws:dynamic-wsdl 
    		id="CustKeyService" 
    		portTypeName="CustKey"
    		locationUri="/services/"
    		targetNamespace="http://acdt1403:8080/CustKeyService" 
    		createSoap11Binding="true"
    		serviceName="CustKeyService">
    		<!--  requestSuffix="Request" responseSuffix="Response"-->
    
    		<sws:xsd location="/WEB-INF/classes/CustKeyService.xsd"/>
    	</sws:dynamic-wsdl>
    	
    	<beans:bean id ="custKeyService" class="com.americancentury.custdataservice.CustKeyService"/>
    	<beans:bean id="custDataDao" class = "com.americancentury.spidao.CustDataDao"/>
    	
    	 <beans:bean id="custKeyServiceEndpoint" class="com.americancentury.custdataservice.CustKeyServiceEndpoint">
    	 	<beans:constructor-arg ref="custKeyService" />
    	 </beans:bean>
    Endpoint method
    Code:
    @PayloadRoot(namespace=NAMESPACE_URI, localPart = "getTaxID")
    		public void handleTaxIdRequest(@RequestPayload Element foo)
    				throws Exception{
    				logger.debug("Entered handleTaxIdRequest method");		
    				System.out.println("Entered handleTaxIdRequest");
    				System.out.println("foo.getValue()+++"+foo.getValue());
    				String custKey = foo.getValue();
    				System.out.println(custKey);
    
    				String taxId = custKeyService.getTaxID(custKey);
                                     //add respsone message
    		}

  • #2
    Would it help to see the xsd document defined for the service?

    Comment


    • #3
      It will be very helpful if we denote some time in maintaining our code styles so that it can be modified from time to time.
      Last edited by EmilyJoseph; Feb 12th, 2014, 03:39 AM.

      Comment

      Working...
      X