Results 1 to 4 of 4

Thread: Full SOAP message as XML

  1. #1
    Join Date
    Oct 2008
    Posts
    6

    Default Full SOAP message as XML

    Hello,

    Could somebody please post a reference to or copy & paste here an example of an endpoint that takes a full SOAP request message as input and full SOAP response message as output?

    I know how to handle the XML but I'm confused about the SWS specifics.

    I've browsed through the "documentation" and I couldn't find any simple example of that.

    Thanks

  2. #2

    Default

    Can you explain what you're trying to achieve?
    I you want access to the various SOAP specific elements of the request and the response, you can in a MessageEndpoint or an EndpointInterceptor (depends on what you want to do), get the request/response from the MessageContext and cast it to a SoapMessage (assuming you're using SOAP) and then get end interact with the SOAP envelope/header/body.
    Is that what you need?
    Tareq Abedrabbo

    My Twitter
    My Blog

  3. #3
    Join Date
    Oct 2008
    Posts
    6

    Default

    Thanks for the quick reply tareq. Form what I could see in the doc yes MessageEndpoint with MessageContext is what would be the easier to use. Are there any example out there of these? And yes in this case I use SOAP.

    So more concrete questions:
    The invoke method in MessageEndpoint is void: how do I send the response?
    What's the shortest way (or any way) to go from MessageContext to raw XML and back from raw XML to the response?

    Thanks

    PS: I'd rather manipulate my XML, receive, manipulate, send it and do as less as possible in the spring-ws-servlet.xml file
    Last edited by PierreDel; Feb 26th, 2009 at 09:11 AM.

  4. #4
    Join Date
    Oct 2008
    Posts
    6

    Default

    Using "AbstractMarshallingPayloadEndpoint" seems to work, but unfortunately, the WSDL generated doesn't comport any operation.

    Code:
    package com.pwet.finance.stockquote.ws;
    
    import org.springframework.oxm.Marshaller;
    import org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint;
    import org.springframework.util.xml.DomUtils;
    import org.springframework.ws.server.endpoint.AbstractDomPayloadEndpoint;
    import org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint;
    
    
    import com.pwet.data.generic.*;
    
    public class GenericEndpointMarshalled extends AbstractMarshallingPayloadEndpoint {
    
    
    	public GenericEndpointMarshalled(){}
    	
    	public GenericEndpointMarshalled(Marshaller marshaller) {
            super(marshaller);
        }
    	
    	protected Object invokeInternal(Object request) throws Exception {
    		
    		MessageDocument requestDoc = (MessageDocument)request;
    		
    		//Here do stuff with request
    		
            return requestDoc;
    	}
    }
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified" targetNamespace="generic.data.pwet.com" xmlns:tns="generic.data.pwet.com">
    	<xs:element name="message">
    	  <xs:complexType>
    		<xs:sequence>
    		  <xs:any minOccurs="0"/>
    		</xs:sequence>
    	  </xs:complexType>
    	</xs:element>
    </xs:schema>
    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"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
        <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
            <property name="defaultEndpoint" ref="genericEndpoint"/>
        </bean>
    
        <bean id="genericEndpoint" class="com.pwet.finance.stockquote.ws.GenericEndpointMarshalled">
    		<constructor-arg ref="xmlbeansMarshaller"/>
    	</bean>
    
    	<bean id="xmlbeansMarshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMarshaller" />
    
        <bean id="generic" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
            <property name="schema" ref="schema"/>
            <property name="portTypeName" value="Generic"/>
            <property name="locationUri" value="http://localhost:8080/genericService/genericService"/>
        </bean>
    
        <bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
            <property name="xsd" value="/WEB-INF/generic.xsd"/>
        </bean>
    
    </beans>
    Code:
    <wsdl:definitions targetNamespace="generic.data.pwet.com">
    <wsdl:types>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="generic.data.pwet.com">
    <xs:element name="message">
    <xs:complexType>
    <xs:sequence>
    <xs:any minOccurs="0"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    </wsdl:types>
    <wsdl:portType name="Generic">
      </wsdl:portType>
    <wsdl:binding name="GenericSoap11" type="tns:Generic">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    </wsdl:binding>
    <wsdl:service name="GenericService">
    <wsdl:port binding="tns:GenericSoap11" name="GenericSoap11">
    <soap:address location="http://localhost:8080/genericService/genericService"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>

Posting Permissions

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