gpt4 book ai didi

soap - Mule SOAP 客户端包装器作为参数而不是对象数组

转载 作者:行者123 更新时间:2023-12-04 04:38:52 32 4
gpt4 key购买 nike

我创建了一个示例 Mule 流,首先根据 http://www.mulesoft.org/documentation/display/current/Consuming+Web+Services+with+CXF 使用 CXF 生成客户端类指南。

流程开始于 localhost:8081/test . parametersObjectArray将任何消息转换为 Web 服务方法调用所需的硬编码对象数组,如下所示:

package com.test.example.transformers;

import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractTransformer;

public class GetCustomersArrayTransformer extends AbstractTransformer {

@Override
protected Object doTransform(Object src, String enc)
throws TransformerException {
Object[] msg = new Object[3];
msg[0] = 10;
msg[1] = 0;
msg[2] = null;

return msg;
}
}

当在流中使用此转换器将消息传递给 jaxws-client 时节点,一切都按预期工作:
<custom-transformer name="parametersObjectArray" class="com.test.example.transformers.GetCustomersArrayTransformer" doc:name="Java"/>   


<flow name="mulecartFlow" doc:name="mulecartFlow">
<http:inbound-endpoint exchange-pattern="one-way" host="localhost" port="8081" doc:name="HTTP" path="test"/>
<transformer ref="parametersObjectArray" doc:name="Java"></transformer>
<https:outbound-endpoint exchange-pattern="request-response" host="12.34.56.78" port="1234" path="services/SOAP/TestEndpoint" doc:name="HTTP" connector-ref="httpsConnector" method="POST">
<cxf:jaxws-client clientClass="com.test.TestEndpointService" enableMuleSoapHeaders="true" doc:name="SOAP" operation="getCustomers" port="TestEndpoint" />
</https:outbound-endpoint>
<transformer ref="customerInfoTypesToString" doc:name="Transformer Reference"/>
<logger level="INFO" doc:name="Logger" message="#[message:payload]"/>
</flow>

我想使用包装对象,以便参数清晰且类型安全:
package com.test.example.transformers;

import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractTransformer;

import com.test.GetCustomers;

public class GetCustomersObjectTransformer extends AbstractTransformer {

@Override
protected Object doTransform(Object src, String enc)
throws TransformerException {
GetCustomers soapRequest = new GetCustomers();
soapRequest.setStartIndex(0);
soapRequest.setMaxBatchSize(1);

return soapRequest;
}

}

但是,这似乎不起作用。我注意到手册页指出:

Note: the CXF transport doesn't support wrapper-style web service method calls. You may need to create a binding file or change the WSDL directly



这是什么意思?如何将包装所有方法参数的包装器对象发送到 Web 服务方法?

最佳答案

添加:

    <jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>

wsdl:portType CXF 将生成您想要的包装器对象。

另外,请注意,创建 Java 转换器来设置有效负载是过​​大的:使用 set-payload用一个简单的 MEL 表达式,你会很好。

关于soap - Mule SOAP 客户端包装器作为参数而不是对象数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19226223/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com