2014-03-04 84 views
0

我正在尝试将MuleStudio作为代理服务来测试,我想用一个静态的XML请求字符串来做一个非常简单的SOAP请求 - 我目前在Mule中做一个简单的POST有问题, GET方法工作并附加SOAPAction头也可以,我的问题是设置一个XML字符串/有效载荷作为POST正文并获得响应。MuleStudio请求HTTP POST正文

的文档是有限的任何帮助将是惊人的...

这里是我目前有:

<?xml version="1.0" encoding="UTF-8"?> 
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" 
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
    xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" 
    version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
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/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-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/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd 
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd"> 
    <append-string-transformer message="testets" name="Append_String" doc:name="Append String"/> 
    <flow name="testFlow1" doc:name="testFlow1"> 
     <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/> 
     <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="80" method="GET" followRedirects="true" doc:name="HTTP" > 
     <set-property propertyName="SOAPAction" value="http://tempuri.org/getCurrencies" />   
     </http:outbound-endpoint> 
    </flow> 
</mule> 

回答

1

设置POST身体HTTP出站是骡子微不足道。无论目前的有效载荷是什么,都将作为POST机构发送。尝试这个例子来看看如何HTTP POST,在骡头,和HTTP响应工作:

<flow name="testFlow1"> 
    <http:inbound-endpoint exchange-pattern="request-response" host="0.0.0.0" port="8080" path="path1"/> 
    <set-payload value="my post data"/> 
    <http:outbound-endpoint exchange-pattern="request-response" host="0.0.0.0" port="8080" path="path2" method="POST"> 
    <set-property propertyName="SOAPAction" value="http://tempuri.org/getCurrencies" /> 
    </http:outbound-endpoint> 
    <object-to-string-transformer/> 
    <logger message="reply from post:#[payload]" level="INFO"/> 
</flow> 

<flow name="testFlow2"> 
    <http:inbound-endpoint exchange-pattern="request-response" host="0.0.0.0" port="8080" path="path2"/>  
    <object-to-string-transformer/> 
    <logger message="post data:#[payload]" level="INFO"/> 
    <logger message="my header:#[message.inboundProperties['SOAPAction']]" level="INFO"/> 
    <set-payload value="my reply"/> 
</flow> 
+0

感谢安东,你帮我指出了正确的方向,我仍然很新的骡子,我我注意到它在内容类型标题方面非常严格... –

1

有创造骡子流SOAP请求.. 不同的方式可以使用一套有效载荷和直接设置SOAP XML有..
其他选项是喜欢用XSLT有创建SOAP请求
参考: - https://developer.mulesoft.com/docs/display/current/XSLT+Transformer
您还可以设置SOAP请求的文件,并使用文件连接器
裁判它叫成一个流程: - https://developer.mulesoft.com/docs/display/current/File+Connector
和是需要你的HTTP出站端点之前设置这些选项,并设置HTTP出站端点方法POST