WSO2 esb api does not interpret xml when SOAPAction present - wso2

I have an Oracle SOA HTTP Binding that sends the XML message into WSO2 ESB. This message (incorrectly) contains a SOAPAction header. When this header is present, ESB gives the error: org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found .
How can I fix this?

WSO2 ESB does not have any issues with processing SOAPAction header. According to the error exception you are getting, it is related to the content-type of your request. Please check on the content-type of the message coming in to ESB. If the content type is text/xml, then ESB expects a SOAP message and in this particular scenario, you will get this exception if the message does not contain the soap header. If it is not a SOAP message, then change the content-type to application/xml.

Related

SOAP and HTTP response codes

Is SOAP end-point over HTTP expected to return any status code except 200 and 500? I have a SOAP end-point that has some business logic to reject requests when there are too many of them. I wonder what is the correct HTTP response code in this case - 500 or 429? The SOAP specification seems vague to me:
SOAP HTTP follows the semantics of the HTTP Status codes for
communicating status information in HTTP. For example, a 2xx status
code indicates that the client's request including the SOAP component
was successfully received, understood, and accepted etc.
In case of a SOAP error while processing the request, the SOAP HTTP
server MUST issue an HTTP 500 "Internal Server Error" response and
include a SOAP message in the response containing a SOAP Fault element
(see section 4.4) indicating the SOAP processing error.
In short SOAP uses HTTP/HTTPS as a transport. It is not bound to HTTP/S. SOAP can also use SMTP and JMS as a transport. Yes you can do SOAP via email.
The 200 and 500 error codes mentioned is just the standard way of letting SOAP know that the message contains a successful or failed SOAP request. Thus I would use 500 with the error logged in the standard SOAP fault.

Error sending MTOM request to WSO2 ESB

I'm using wso2 ESB in order to mediate request from a client to a web service, but I can't send MTOM attachments. ESB replies with error "Mime parts not found".
The sample MTOMSwASampleService give me same error too.
Can anyone help me? How can I send MTOM attachments through ESB?
Try preserving Content-type header and see.
Add the following property to repository/conf/passthru-http.properties file.
http.headers.preserve=Content-Type

WSO2 - ESB server 4.7 Hangs- when an invalid json format is given as input for rest API

A REST API has been defined ESB. What we have observed is if the json format (invalid json),
the request is hanging and the server doesn't give any response. Ideally it should throw some
error at least and it should not hang.
I had the same situation in WSO2 4.8.1. Try to change JsonStreamBuilder in your axis2.xml to JsonBuilder from (org.apache.synapse.commons.json) or use your own implementation.

SOAP Envelope can not have children other than SOAP Header and Body

With the update to version 4.6.0 wso2esb, the error began to occur:
org.apache.axiom.soap.SOAPProcessingException: SOAP Envelope can not have children other than SOAP Header and Body
When using security services.
How do I resolve the error?

Apache CXF (2.6.1): Client gets "Content is not allowed in prolog"

I'm using Apache CXF (2.6.1) in my java application to consume 3rd party Web Service. But I have a problem with it, in particular if I use JAXB for databinding while stubs generation my client will always send requests with "header" like "--uuid:e47f145b-38f7-4402-8eec-657d71bc8ad4..." (see client request below), i.e. besides XML part there is some special info...
It looks like this special info causes error reply from server "Content is not allowed in prolog" (see server response below), i.e. server is not expecting such body. What is interesting here is that if I generate stubs using XMLBEANS for databinding everything starts to work just fine (and there is no such "special" info in request body, only XML). After some googling I suspect that my client for some reason tries to use MTOM (with JAXB) and I don't know how to turn it off. I've already tried the following to turn MTOM off (with no luck):
((BindingProvider)port).getRequestContext().put("mtom-enabled", Boolean.FALSE);
((BindingProvider)port).getRequestContext().put("write.attachments", Boolean.FALSE);
((BindingProvider)port).setMTOMEnabled(false);
Please help I would really want to move to JAXB since it's much more compact in comparison with XMLBEANS...
Client code:
AdminServiceV2 ws = new AdminServiceV2();
AdminV2 port = ws.getAdminPortV2();
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy();
authorizationPolicy.setUserName("user1");
authorizationPolicy.setPassword("password1");
authorizationPolicy.setAuthorizationType("Basic");
http.setAuthorization(authorizationPolicy);
try {
port.getUsersInfo("user1");
} catch (Exception e) {
e.printStackTrace();
}
Client request:
--uuid:e47f145b-38f7-4402-8eec-657d71bc8ad4
Content-Type: text/xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <root.message#cxf.apache.org>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getUsersInfo xmlns:ns2="http://service.admin.ws.five9.com/v2/"><userNamePattern>user1</userNamePattern></ns2:getUsersInfo></soap:Body></soap:Envelope>
--uuid:e47f145b-38f7-4402-8eec-657d71bc8ad4--
Server response:
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><env:Fault xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><faultcode>env:Client</faultcode><faultstring>org.xml.sax.SAXParseException: Content is not allowed in prolog.</faultstring></env:Fault></env:Body></env:Envelope>
Thanks,
Konstantin
No CXF request ever starts normally with --uuid. That is part-way through a multi-part HTTP message. With or without MTOM, a normal SOAP message consists of an HTTP header followed by the XML content. If it's MTOM, the HTTP header declared multipart, and then there are multipart separators and sub-headers.
If you are using a custom front-end to ask for 'plain XML' messages without the usual required HTTP headers, then that, combined with MTOM, might have the undesirable effect at hand.
JAXB will generally only enable MTOM if you have #XmlMimeType("application/octet-stream") annotations(s). You should also look at the WSDL/XSD for the service and see if it has xmime annotations in there.
See the CXF MTOM doc for more details.
You haven't specified the CXF version or how you configured your CXF client endpoint. You might get better assistance by sending all that data to the CXF user mailing list.
The question was answered on CXF user mailing list by Daniel Kulp, for details see
http://cxf.547215.n5.nabble.com/Apache-CXF-2-6-1-Client-gets-Content-is-not-allowed-in-prolog-td5713009.html#a5713055. In short the problem was with WSDL (it contains swaRefs) that forces CXF to send messages like with attachments. Workaround was also provided...