I have a specific need for a SOAP endpoint. We use spring ws 2.4.0 framework at my organization.
What we really need is an endpoint that gets the SOAP message itself and returns a String. The message payload is XML data. All we need to do can be accomplished using the MessageContext object. We have no need for unmarshalled XML or such.
I've been doing some experiments but always end up with the following error:
No adapter for endpoint [public java.lang.String org.company.endpoint.MyEndpoint.receiveSOAP(org.springframework.ws.context.MessageContext) throws java.lang.Exception]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?
I probably have a ton of unnecessary configurations messing up my Spring ws framework right now. So any ideas how I can do this with minimal configuration:
- receive SOAP with XML payload
- SOAP message caught in Endpoint method
- do my thing with messageContext parameter
- return String (XML payload will do fine too)
Preferably skipping XML->POJO conversion, since the payload XML is huge
You can achieve this by using the DomPoxMessageFactory and a simple implementation of MessageEndpoint you write yourself. Like this:
Your spring configuration would contain:
The message string you obtain in your endpoint would contain the whole XML, so including the SOAP envelope and such. If you want only the message body, do
and you wil get a DOM Source for the payload in which you can look up the node containing the message content. (First child node is the envelope, the child node at index 3 of that node is the body.)