我想使用Mule使用SOAP Web服务,但是我无法在有效负载中传递参数,因为我理解的是ZRFCFUNCIONARIOLISTA类的对象,但是给出了以下消息: 参数类型不匹配。无法通过端点路由事件:org.mule.module.cxf.CxfOutboundMessageProcessor。消息有效内容的类型为:Class
如何通过有效负载或其他有效方式传递正确的参数?
遵循流程
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" 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="CE-3.4.0"
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/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
<spring:beans>
<spring:bean id="Bean" name="Bean" class="sap.bapi.fornecedor.ZRFCFUNCIONARIOLISTA"/>
</spring:beans>
<flow name="sap6Flow1" doc:name="sap6Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<set-payload value="#[sap.bapi.fornecedor.ZRFCFUNCIONARIOLISTA]" doc:name="Set Payload"/>
<cxf:jaxws-client operation="ZRFC_FUNCIONARIO_LISTA" clientClass="sap.bapi.fornecedor.ZRFCFUNCIONARIOLISTAService" port="ZRFC_FUNCIONARIO_LISTAPortType" doc:name="SOAP"/>
</flow>
</mule>
关注wsdl:
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:s0="urn:sap-com:document:sap:rfc:functions" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="urn:sap-com:document:sap:rfc:functions">
<types>
<xsd:schema targetNamespace="urn:sap-com:document:sap:rfc:functions">
<xsd:element name="ZRFC_FUNCIONARIO_LISTA">
<xsd:complexType>
<xsd:all/>
</xsd:complexType>
</xsd:element>
<xsd:element name="ZRFC_FUNCIONARIO_LISTA.Response">
<xsd:complexType>
<xsd:all>
<xsd:element name="LISTA">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="s0:ZSDE002"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ZSDE002">
<xsd:sequence>
<xsd:element name="LIFNR" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="NAME1" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="35"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</types>
<message name="ZRFC_FUNCIONARIO_LISTAInput">
<part name="parameters" element="s0:ZRFC_FUNCIONARIO_LISTA"/>
</message>
<message name="ZRFC_FUNCIONARIO_LISTAOutput">
<part name="parameters" element="s0:ZRFC_FUNCIONARIO_LISTA.Response"/>
</message>
<portType name="ZRFC_FUNCIONARIO_LISTAPortType">
<operation name="ZRFC_FUNCIONARIO_LISTA">
<input message="s0:ZRFC_FUNCIONARIO_LISTAInput"/>
<output message="s0:ZRFC_FUNCIONARIO_LISTAOutput"/>
</operation>
</portType>
<binding name="ZRFC_FUNCIONARIO_LISTABinding" type="s0:ZRFC_FUNCIONARIO_LISTAPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="ZRFC_FUNCIONARIO_LISTA">
<soap:operation soapAction="http://www.sap.com/ZRFC_FUNCIONARIO_LISTA"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="ZRFC_FUNCIONARIO_LISTAService">
<documentation>SAP Service ZRFC_FUNCIONARIO_LISTA via SOAP</documentation>
<port name="ZRFC_FUNCIONARIO_LISTAPortType" binding="s0:ZRFC_FUNCIONARIO_LISTABinding">
<soap:address location="url service"/>
</port>
</service>
</definitions>
关注服务类:
package sap.bapi.fornecedor;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;
/**
* SAP Service ZRFC_FUNCIONARIO_LISTA via SOAP
*
* This class was generated by Apache CXF 2.5.1
* 2014-05-05T09:01:25.221-03:00
* Generated source version: 2.5.1
*
*/
@WebServiceClient(name = "ZRFC_FUNCIONARIO_LISTAService",
wsdlLocation = ".../wsdl11.services_zrfc_funcionario_lista.wsdl",
targetNamespace = "urn:sap-com:document:sap:rfc:functions")
public class ZRFCFUNCIONARIOLISTAService extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("urn:sap-com:document:sap:rfc:functions", "ZRFC_FUNCIONARIO_LISTAService");
public final static QName ZRFCFUNCIONARIOLISTAPortType = new QName("urn:sap-com:document:sap:rfc:functions", "ZRFC_FUNCIONARIO_LISTAPortType");
static {
URL url = null;
try {
url = new URL(".../wsdl11.services_zrfc_funcionario_lista.wsdl");
} catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(ZRFCFUNCIONARIOLISTAService.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", ".../wsdl11.services_zrfc_funcionario_lista.wsdl");
}
WSDL_LOCATION = url;
}
public ZRFCFUNCIONARIOLISTAService(URL wsdlLocation) {
super(wsdlLocation, SERVICE);
}
public ZRFCFUNCIONARIOLISTAService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public ZRFCFUNCIONARIOLISTAService() {
super(WSDL_LOCATION, SERVICE);
}
//This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
//API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
//compliant code instead.
public ZRFCFUNCIONARIOLISTAService(WebServiceFeature ... features) {
super(WSDL_LOCATION, SERVICE, features);
}
//This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
//API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
//compliant code instead.
public ZRFCFUNCIONARIOLISTAService(URL wsdlLocation, WebServiceFeature ... features) {
super(wsdlLocation, SERVICE, features);
}
//This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
//API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
//compliant code instead.
public ZRFCFUNCIONARIOLISTAService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns ZRFCFUNCIONARIOLISTAPortType
*/
@WebEndpoint(name = "ZRFC_FUNCIONARIO_LISTAPortType")
public ZRFCFUNCIONARIOLISTAPortType getZRFCFUNCIONARIOLISTAPortType() {
return super.getPort(ZRFCFUNCIONARIOLISTAPortType, ZRFCFUNCIONARIOLISTAPortType.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns ZRFCFUNCIONARIOLISTAPortType
*/
@WebEndpoint(name = "ZRFC_FUNCIONARIO_LISTAPortType")
public ZRFCFUNCIONARIOLISTAPortType getZRFCFUNCIONARIOLISTAPortType(WebServiceFeature... features) {
return super.getPort(ZRFCFUNCIONARIOLISTAPortType, ZRFCFUNCIONARIOLISTAPortType.class, features);
}
}
类端口:
package sap.bapi.fornecedor;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by Apache CXF 2.5.1
* 2014-05-05T09:01:25.210-03:00
* Generated source version: 2.5.1
*
*/
@WebService(targetNamespace = "urn:sap-com:document:sap:rfc:functions", name = "ZRFC_FUNCIONARIO_LISTAPortType")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface ZRFCFUNCIONARIOLISTAPortType {
@WebResult(name = "ZRFC_FUNCIONARIO_LISTA.Response", targetNamespace = "urn:sap-com:document:sap:rfc:functions", partName = "parameters")
@WebMethod(operationName = "ZRFC_FUNCIONARIO_LISTA", action = "http://www.sap.com/ZRFC_FUNCIONARIO_LISTA")
public ZRFCFUNCIONARIOLISTAResponse zrfcFUNCIONARIOLISTA(
@WebParam(partName = "parameters", name = "ZRFC_FUNCIONARIO_LISTA", targetNamespace = "urn:sap-com:document:sap:rfc:functions")
ZRFCFUNCIONARIOLISTA parameters
);
}
和客户类:
package sap.bapi.fornecedor;
/**
* Please modify this class to meet your needs
* This class is not complete
*/
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by Apache CXF 2.5.1
* 2014-05-05T09:01:25.082-03:00
* Generated source version: 2.5.1
*
*/
public final class ZRFCFUNCIONARIOLISTAPortType_ZRFCFUNCIONARIOLISTAPortType_Client {
private static final QName SERVICE_NAME = new QName("urn:sap-com:document:sap:rfc:functions", "ZRFC_FUNCIONARIO_LISTAService");
private ZRFCFUNCIONARIOLISTAPortType_ZRFCFUNCIONARIOLISTAPortType_Client() {
}
public static void main(String args[]) throws java.lang.Exception {
URL wsdlURL = ZRFCFUNCIONARIOLISTAService.WSDL_LOCATION;
if (args.length > 0 && args[0] != null && !"".equals(args[0])) {
File wsdlFile = new File(args[0]);
try {
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
ZRFCFUNCIONARIOLISTAService ss = new ZRFCFUNCIONARIOLISTAService(wsdlURL, SERVICE_NAME);
ZRFCFUNCIONARIOLISTAPortType port = ss.getZRFCFUNCIONARIOLISTAPortType();
{
System.out.println("Invoking zrfcFUNCIONARIOLISTA...");
sap.bapi.fornecedor.ZRFCFUNCIONARIOLISTA _zrfcFUNCIONARIOLISTA_parameters = null;
sap.bapi.fornecedor.ZRFCFUNCIONARIOLISTAResponse _zrfcFUNCIONARIOLISTA__return = port.zrfcFUNCIONARIOLISTA(_zrfcFUNCIONARIOLISTA_parameters);
System.out.println("zrfcFUNCIONARIOLISTA.result=" + _zrfcFUNCIONARIOLISTA__return);
}
System.exit(0);
}
}
答案 0 :(得分:0)
不确定Spring bean的用途是什么:你想要为每个请求实例化一个新的sap.bapi.fornecedor.ZRFCFUNCIONARIOLISTA
,这样你就不需要一个bean了。
您必须在MEL中使用new
关键字来实例化请求对象:
<set-payload value="#[new sap.bapi.fornecedor.ZRFCFUNCIONARIOLISTA()]" doc:name="Set Payload"/>
请注意,我认为这还不够:我认为您可以在此对象上设置属性以形成有效请求。您可以通过调用setter来扩展MEL表达式。