0

我正在使用 wso2esb 4.8.1,所以我的客户端正在发送如下所示的未形成的 xml。

<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>

在上面的请求中, xsi前缀命名空间没有被声明所以它在 wso2esb 服务器中给出如下错误。

 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)

它是一个属性,因此他们没有为此声明任何名称空间。 在 java.lang.Thread.run(Thread.java:744) 引起:org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException:ParseError at [row,col]:[4,41] 消息:http ://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?r:user&xsi:type&xsi

如何在 wso2esb 中禁用 xml 验证,或者我将如何处理这种消息,如果我声明命名空间它工作正常,但我的旧系统没有在其他 ESB 相同请求工作正常的地方发送这个。

我尝试使用 Http、NHttp 传输更改axis2文件中的不同消息构建器。

提前致谢。

4

1 回答 1

1

You can achieve this using custom axis2 message builders

  1. Write a custom message builder which implements org.apache.axis2.builder.Builder
  2. The custom message builder should implement the following method

    public OMElement processDocument(InputStream inputStream, String contentType, MessageContext messageContext) throws AxisFault

  3. 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)

  4. Create a jar file for your custom message builder and drop it in %wso2esb-home%\repository\components\lib

  5. 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" />
    
  6. Finally restart the wso2 esb server to get reflect your changes.

于 2015-01-30T22:03:10.337 回答