Mulesoft将XML发布到SOAP

时间:2014-04-15 12:38:21

标签: xml soap mule

我有一个JSON主体,通过DATAMAPPER,我将内容转换为XML。转换成功运行,如果我将XML保存到文件位置,则会产生下面的XML:

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/">
  <ns0:Body>
    <ns1:UpdateObject xmlns:ns1="SaaS.website">
      <ns1:sessionKey>sessionKeygoeshere</ns1:sessionKey>
      <ns1:tenantId>tenantIdgoeshere</ns1:tenantId>
      <ns1:commandData>
        <ns1:ObjectId>ObjectIdgoeshere</ns1:ObjectId>
        <ns1:ObjectType>Incident#</ns1:ObjectType>
        <ns1:Fields>
          <ns1:ObjectCommandDataFieldValue>
            <ns1:Name>FieldName</ns1:Name>
            <ns1:Value>1234567</ns1:Value>
          </ns1:ObjectCommandDataFieldValue>
        </ns1:Fields>
      </ns1:commandData>
    </ns1:UpdateObject>
  </ns0:Body>
</ns0:Envelope>

但是,我需要做的是将此XML发布到SOAP Web服务以将记录更新到第三方网站。我的配置如下:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd">
    <data-mapper:config name="json_to_pojo_2" transformationGraphPath="json_to_pojo_2.grf" doc:name="json_to_pojo_2"/>
    <data-mapper:config name="json_to_xml" transformationGraphPath="json_to_xml.grf" doc:name="json_to_xml"/>

<flow name="temp_arraytoobjectFlow1" doc:name="temp_arraytoobjectFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="temp" contentType="application/json" doc:name="HTTP"/>
        <data-mapper:transform config-ref="json_to_xml" doc:name="JSON To XML"/>
        <cxf:proxy-client payload="envelope" doc:name="SOAP"/>
        <https:outbound-endpoint exchange-pattern="request-response" method="POST" address="https://website.com/ServiceAPI/Integration.asmx" mimeType="text/xml" followRedirects="true" contentType="text/xml" keep-alive="true" doc:name="HTTP"/>
    </flow>
    <sub-flow name="file" doc:name="file">
        <file:outbound-endpoint path="/Users/eyu/Desktop/xmatters" outputPattern="temparray_result.xml" responseTimeout="10000" doc:name="File"/>
    </sub-flow>
</mule>

不幸的是,当我运行流程并发帖子时(如果我的出站点是文件那么我使用的帖子完全相同),我收到以下错误:

ERROR 2014-04-16 00:27:52,403 [[integration].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=https://website.com/ServiceAPI/Integration.asmx, connector=HttpsConnector
{
  name=connector.https.mule.default
  lifecycle=start
  this=20753fe6
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[https]
  serviceOverrides=<none>
}
,  name='endpoint.https.website.com.ServiceAPI.Integration.asmx', mep=REQUEST_RESPONSE, properties={followRedirects=true, http.method=POST, keepAlive=true, Content-Type=text/xml}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: PostMethod
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Entity enclosing requests cannot be redirected without user intervention (java.lang.IllegalArgumentException)
  org.apache.commons.httpclient.methods.EntityEnclosingMethod:225 (null)
2. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=https://website.com/ServiceAPI/Integration.asmx, connector=HttpsConnector
{
  name=connector.https.mule.default
  lifecycle=start
  this=20753fe6
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[https]
  serviceOverrides=<none>
}
,  name='endpoint.https.website.com.ServiceAPI.Integration.asmx', mep=REQUEST_RESPONSE, properties={followRedirects=true, http.method=POST, keepAlive=true, Content-Type=text/xml}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: PostMethod (org.mule.api.transport.DispatchException)
  org.mule.transport.AbstractMessageDispatcher:109 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.IllegalArgumentException: Entity enclosing requests cannot be redirected without user intervention
    at org.apache.commons.httpclient.methods.EntityEnclosingMethod.setFollowRedirects(EntityEnclosingMethod.java:225)
    at org.mule.transport.http.HttpClientMessageDispatcher.getMethod(HttpClientMessageDispatcher.java:216)
    at org.mule.transport.http.HttpClientMessageDispatcher.doSend(HttpClientMessageDispatcher.java:265)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

Already tried the following:

1. Changed the XML schema to be the structure with the soap headers and changed the SOAP payload to "body"
2. Turn off Follow-redirect - more errors
3. Switched operation to jax-ws client but even further errors occurred.

任何帮助都会对此非常感激。环境细节如下:

Mule Studio版本:3.5.0 Build Id:201402101410

使用以下java版本运行MAC OS X 10.9.2(13C64): java版&#34; 1.7.0_51&#34; Java(TM)SE运行时环境(版本1.7.0_51-b13) Java HotSpot(TM)64位服务器VM(内置24.51-b03,混合模式)

0 个答案:

没有答案