Results 1 to 4 of 4

Thread: Server did not recognize the value of HTTP Header SOAPAction

  1. #1

    Default Server did not recognize the value of HTTP Header SOAPAction

    Hi,
    I'm getting an error when trying to invoke a .NET web service.

    This is my bean config:
    Code:
    <bean id="challengeDecoder" class="ChallengeDecoder">
        <property name="defaultUri" value="http://localhost:5007/LicensingWS.asmx"/>
        <property name="request" value="classpath:com/spring/ws/ChallengeRequest.xml"/>
        <property name="action" value="http://server.com/vd/pc/drm/licensing/DecodeChallenge"/>
    </bean>
    This is the method that invokes the web service:
    Code:
    public void decodeChallenge() throws IOException {
        Source requestSource = new ResourceSource(request);
        StringResult result = new StringResult();
        getWebServiceTemplate().sendSourceAndReceiveToResult(requestSource, new ActionCallback(action), result);
        System.out.println(result);
    }
    and the exception being thrown:
    Code:
    Exception in thread "main" org.springframework.ws.soap.client.SoapFaultClientException: Server did not recognize the value of HTTP Header SOAPAction: .
    	at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:37)
    	at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:668)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:502)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:440)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:395)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:341)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:332)
    	at com.c4.spring.ws.ChallengeDecoder.decodeChallenge(ChallengeDecoder.java:34)
    	at com.c4.spring.ws.ChallengeDecoder.main(ChallengeDecoder.java:42)
    Is there anything wrong in the code or the config?

    Regards,
    Juan

  2. #2

    Default

    My mistake,
    in the code I should have put:
    Code:
    getWebServiceTemplate().sendSourceAndReceiveToResult(requestSource, new SoapActionCallback(action), result);
    Juan

  3. #3

    Talking

    This may be a bit late but I thought I'd write something here to show how to solve this problem.

    The problem is caused by using the wrong SOAP version. You are trying to make a request to a SOAP 1.2 webservice with a SOAP 1.1 request.

    In the header of your request your soap namespace is declared as - http://schemas.xmlsoap.org/soap/envelope/
    This is the version 1.1 namespace.

    You need to set the SOAP 1.2 namespace as this - http://www.w3.org/2003/05/soap-envelope

    In your application context you will be creating a WebServiceTemplate bean which will have a SoapMessageFactory injected.

    Code:
    <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
            <constructor-arg ref="soapMessageFactory"/>
    
    ....
    The soapMessageFactory bean should be declared like so, where you set the set the soapVersion property with a static field like so -

    Code:
     <bean id="soapMessageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
            <property name="soapVersion">
                <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12"/>
            </property>
        </bean>
    Make sure you declare the spring-utils namespace in the application context like so -

    Code:
    <beans xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
    You should now see the correct soap namespace in the request and it will recieve a valid response.

    Hope that helps anyone else with the same issue.

  4. #4
    Join Date
    Jul 2012
    Posts
    3

    Default

    Hello,

    I have this exact same issue and I did follow what you have said:

    Here is my config :

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
    	xmlns:util="http://www.springframework.org/schema/util"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
    	<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
    		<property name="soapVersion">
    			<util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12" />
    		</property>
    	</bean>
    	<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
    		<constructor-arg ref="messageFactory" />
    		<property name="defaultUri" value="https://ecomapi.networksolutions.com/soapservice.asmx" />
    		<property name="messageSender">
    			<bean class="org.springframework.ws.transport.http.CommonsHttpMessageSender" />
    		</property>
    	</bean>
    </beans>
    and here is my Java client:

    Code:
    import java.io.StringReader;
    
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.stream.StreamSource;
    
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.test.context.ContextConfiguration;
    import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
    import org.springframework.ws.WebServiceMessage;
    import org.springframework.ws.client.WebServiceIOException;
    import org.springframework.ws.client.core.WebServiceTemplate;
    import org.springframework.ws.soap.SoapMessage;
    import org.springframework.ws.soap.client.SoapFaultClientException;
    import org.springframework.ws.soap.client.core.SoapActionCallback;
    
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = { //
    		"classpath:NetworkSolution.xml" })
    public class WebServiceClientTest {
    	 private static final String MESSAGE =
    		       "<?xml version=\"1.0\" encoding=\"utf-8\"?> " + 
    		    		   "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:urn=\"urn:networksolutions:apis\"> " + "................";
    	 	    @Autowired
    		    private WebServiceTemplate webServiceTemplate;	
    	 		
    		    @Test
    		    // send to the configured default URI
    		    public void simpleSendAndReceive() {
    		    	try{
    		        StreamSource source = new StreamSource(new StringReader(MESSAGE));
    		        StreamResult result = new StreamResult(System.out);
    		        SoapActionCallback actionCallBack = new SoapActionCallback("https://ecomapi.networksolutions.com/soapservice.asmx") {
    		        	public void doWithMessage(WebServiceMessage msg) {
    		        		SoapMessage smsg = (SoapMessage)msg;
    		        		smsg.setSoapAction("http://networksolutions.com/ReadOrder");
    		        	}
    		        };
    		        webServiceTemplate.sendSourceAndReceiveToResult(
    		        		"https://ecomapi.networksolutions.com/soapservice.asmx",
    		        	     source,
    //		        	     new SoapActionCallback("http://networksolutions.com/ReadOrder"),
    		        	     actionCallBack,
    		        	     result);
    		        
    		        System.out.println(source.getInputStream().toString());
    		        System.out.println(result.getWriter().toString());
    		    	
    		    	}catch (SoapFaultClientException e) {
    		    		System.out.println(e.getFaultCode());
    		    		System.out.println(e.getFaultStringOrReason());
    		    		System.out.println(e.fillInStackTrace().getLocalizedMessage());
    		    	} catch (WebServiceIOException we) {
    		    		System.out.println(we.getRootCause());
    		    	}
    		    }
    		    
    		  
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •