Hi all,
I struggled for a while before I finally managed to invoke a service with
non-soap message. Here is why.
The following documentation *http://ws.apache.org/axis2/1_5/rest-ws.html*
says:
" if the content type is **text/xml** and if the SOAP Action Headers are
missing, then the Message is treated as a RESTful Message. Else it is
treated as a usual SOAP Message."
However the method HTTPTransportUtils#isRESTRequest does not test the
'text/xml' content-type [1].
So my request fails with the fault below [2]. Changing the content-type to
'application/xml' solved the issue.
Either the code or the documentation needs to be adjusted.
best,
Alexis
[1]
public static boolean isRESTRequest(String contentType) { return
contentType != null &&
(contentType.indexOf(HTTPConstants.MEDIA_TYPE_APPLICATION_XML) > -1 ||
contentType.indexOf(HTTPConstants.MEDIA_TYPE_X_WWW_FORM) >
-1 ||
contentType.indexOf(HTTPConstants.MEDIA_TYPE_MULTIPART_FORM_DATA) > -1);
}
[2]
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode></faultcode><faultstring>First
Element must contain the local name, Envelope , but found
Receive__MessageRequest</faultstring><detail><Exception>org.apache.axis2.AxisFault:
First Element must contain the local name, Envelope , but found
Receive__MessageRequest
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:169)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:142)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.axiom.soap.SOAPProcessingException: First Element must
contain the local name, Envelope , but found Receive__MessageRequest
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:267)
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:214)
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:196)
at
org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:207)
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:161)
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:110)
at
org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:60)
at
org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:192)
at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:140)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:162)
... 17 more
* Closing connection #0
</Exception></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>