Reputation: 1569
I am using wso2esb 4.8.1, So my client is sending unformed xml like below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:open="http://www.openuri.org/">
<soapenv:Header>
<r:valid xmlns:r="http://webmail.w3school.com/use">
<r:user xsi:type="xsd:string">admin</r:user>
<r:password xsi:type="xsd:string">admin</r:password>
</r:valid>
</soapenv:Header>
<soapenv:Body>
<s:Payload xmlns:s="http://www.w3school.com">
<s:request>
<s:name>henry</s:name>
<s:value>2345</s:value>
</s:request>
</s:Payload>
</soapenv:Body>
</soapenv:Envelope>
In above request xsi Prefix namespace has been not declared So its giving error like below in wso2esb server.
TID: [0] [ESB] [2015-01-25 20:42:50,774] ERROR {org.apache.synapse.transport.nhttp.ServerWorker} - Error processing POST request {org.apache.synapse.transport.nhttp.ServerWorker}
org.apache.axis2.AxisFault: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[4,41]
Message: http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?r:user&xsi:type&xsi
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:180)
at org.apache.synapse.transport.nhttp.ServerWorker.processEntityEnclosingMethod(ServerWorker.java:459)
at org.apache.synapse.transport.nhttp.ServerWorker.run(ServerWorker.java:279)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
t java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException:ParseError at [row,col]:[4,41]
Message: http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?r:user&xsi:type&xsi
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.om.impl.llom.OMElementImpl.getNextOMSibling(OMElementImpl.java:336)
Its an attribute so they are not declaring any namespace for that. at java.lang.Thread.run(Thread.java:744) Caused by: org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException:ParseError at [row,col]:[4,41] Message: http://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?r:user&xsi:type&xsi
How to diable the xml validation in wso2esb or how would i process this kind of messages,If I declare namespace its working fine,But my legacy sysytem is not sending this where in other ESB same request working fine.
I have tried with changing different message builders in axis2 file with Http,NHttp transports.
thanks in advance.
Upvotes: 0
Views: 743
Reputation: 91
You can achieve this using custom axis2 message builders
The custom message builder should implement the following method
public OMElement processDocument(InputStream inputStream, String contentType, MessageContext messageContext) throws AxisFault
Implement your custom logic in this method, in your case you can safely replace the xsi:type (hope your soap request is not a rpc encoded style of request otherwise you have to declare a xml namesapce)
Create a jar file for your custom message builder and drop it in %wso2esb-home%\repository\components\lib
Modify the axis2.xml configuration file in %wso2esb-home%\repository\conf\axis2 to accept your custom builder by wso2 synapse engine
<messageBuilder contentType="text/xml" class="builder.CustomSoapBuilder" />
Finally restart the wso2 esb server to get reflect your changes.
Upvotes: 1