我使用MuleSoft XML Only SOAP Web Service example创建了一个WSDL和一个Mule SOAP代理Web服务。我的应用程序工作正常,除了一个问题:当XSD存储在项目根目录以外的任何地方时,它将无法解决。我在/ src / main / resources中创建了服务文件夹和xsd,如示例项目所示,但是当调用服务时,我收到以下错误:
[[bpi.sfdcservices] .connector.http.mule.default.receiver.02] org.apache.cxf.wstx_msv_validation.ResolvingGrammarReaderController:C:\ Users \ mmrg \ MuleStudio \ workspace \ bpi.sfdcservices \ xsd \ sfdcServicesApiTypes .xsd(系统找不到指定的路径) java.io.FileNotFoundException:C:\ Users \ mmrg \ MuleStudio \ workspace \ bpisfdcservices \ xsd \ sfdcServicesApiTypes.xsd(系统找不到指定的路径)
xsd导入为:
<xs:import namespace="BPI/Types" schemaLocation="xsd/sfdcServicesApiTypes.xsd"/>
如果我将此位置更改为
<xs:import namespace="BPI/Types" schemaLocation="sfdcServicesApiTypes.xsd"/>
将xsd放在项目的根目录中,服务正常执行。
可以在类路径/相对路径中引用WSDL。
<cxf:proxy-service namespace="BPI/sfdcServices/1.0" service="sfdcServices" payload="body" doc:name="SOAP" port="sfdcServicesHttpSoapEndpoint" wsdlLocation="service/sfdcServices.wsdl" validationEnabled="true"/>
从我所看到的,我的项目设置与Mule示例相同。我没有在他们的配置中看到任何特定的映射等。我怀疑我的WSDL / XSD编写方式有些不足,因为当我将所有项目文件导入示例项目时它的行为相同,但无法弄清楚问题。
sfdcServices.wsdl:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions name="SFDCServices" targetNamespace="BPI/sfdcServices/1.0" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="BPI/sfdcServices/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:btns="BPI/Types" xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" >
<wsdl:documentation>Services for CRU operations in SFDC</wsdl:documentation>
<wsdl:types>
<xs:schema targetNamespace="BPI/sfdcServices/1.0" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="BPI/Types" schemaLocation="xsd/sfdcServicesApiTypes.xsd"/>
<xs:element name="querySFDCSingleRequest" type="btns:querySFDCSingleRequest"/>
<xs:element name="querySFDCSingleResponse" type="btns:querySFDCSingleResponse"/>
<xs:element name="updateSFDCSingleRequest" type="btns:updateSFDCSingleRequest"/>
<xs:element name="updateSFDCSingleResponse" type="btns:updateSFDCSingleResponse"/>
<xs:element name="createSFDCSingleRequest" type="btns:createSFDCSingleRequest"/>
<xs:element name="createSFDCSingleResponse" type="btns:createSFDCSingleResponse"/>
</xs:schema>
</wsdl:types>
<wsdl:documentation>Query for a single sObject</wsdl:documentation>
<wsdl:message name="querySFDCSingleRequestMsg">
<wsdl:part name="querySFDCSingleRequestPart" element="tns:querySFDCSingleRequest"/>
</wsdl:message>
<wsdl:message name="querySFDCSingleResponseMsg">
<wsdl:part name="querySFDCSingleResponsePart" element="tns:querySFDCSingleResponse"/>
</wsdl:message>
<wsdl:documentation>Update a single sObject</wsdl:documentation>
<wsdl:message name="updateSFDCSingleRequestMsg">
<wsdl:part name="updateSFDCSingleRequestPart" element="tns:updateSFDCSingleRequest"/>
</wsdl:message>
<wsdl:message name="updateSFDCSingleResponseMsg">
<wsdl:part name="updateSFDCSingleResponsePart" element="tns:updateSFDCSingleResponse"/>
</wsdl:message>
<wsdl:documentation>Create a single sObject</wsdl:documentation>
<wsdl:message name="createSFDCSingleRequestMsg">
<wsdl:part name="createSFDCSingleRequestPart" element="tns:createSFDCSingleRequest"/>
</wsdl:message>
<wsdl:message name="createSFDCSingleResponseMsg">
<wsdl:part name="createSFDCSingleResponsePart" element="tns:createSFDCSingleResponse"/>
</wsdl:message>
<wsdl:portType name="sfdcServicesSOAP">
<wsdl:operation name="querySFDCSingle">
<wsdl:input name="querySFDCSingleRequestInput" message="tns:querySFDCSingleRequestMsg"/>
<wsdl:output name="querySFDCSingleResponseOutput" message="tns:querySFDCSingleResponseMsg"/>
</wsdl:operation>
<wsdl:operation name="updateSFDCSingle">
<wsdl:input name="updateSFDCSingleRequestInput" message="tns:updateSFDCSingleRequestMsg"/>
<wsdl:output name="updateSFDCSingleResponseOutput" message="tns:updateSFDCSingleResponseMsg"/>
</wsdl:operation>
<wsdl:operation name="createSFDCSingle">
<wsdl:input name="createSFDCSingleRequestInput" message="tns:createSFDCSingleRequestMsg"/>
<wsdl:output name="createSFDCSingleResponseOutput" message="tns:createSFDCSingleResponseMsg"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="sfdcServicesSoapBinding" type="tns:sfdcServicesSOAP">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="querySFDCSingle">
<soap:operation soapAction="querySFDCSingle" style="document"/>
<wsdl:input name="querySFDCSingleRequestInput">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="querySFDCSingleResponseOutput">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="updateSFDCSingle">
<soap:operation soapAction="updateSFDCSingle" style="document"/>
<wsdl:input name="updateSFDCSingleRequestInput">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="updateSFDCSingleResponseOutput">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="createSFDCSingle">
<soap:operation soapAction="createSFDCSingle" style="document"/>
<wsdl:input name="createSFDCSingleRequestInput">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="createSFDCSingleResponseOutput">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="sfdcServices">
<wsdl:port name="sfdcServicesHttpSoapEndpoint" binding="tns:sfdcServicesSoapBinding">
<soap:address location="http://localhost:8084/BPI/services/sfdcServices"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
sfdcServicesApiTypes.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="BPI/Types" targetNamespace="BPI/Types" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xs:complexType name="querySFDCSingleRequest">
<xs:sequence>
<xs:element name="sObjectType" type="xs:string" nillable="false"/>
<xs:element name="queryFilterField" type="xs:string" nillable="false" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="queryCondition" type="ns1:queryCondition" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="querySFDCSingleResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="updateSFDCSingleRequest">
<xs:sequence>
<xs:element name="sObjectType" type="xs:string" nillable="false"/>
<xs:element name="Id" type="xs:string" nillable="false"/>
<xs:element name="fieldUpdates" type="ns1:dataPair" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="updateSFDCSingleResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="createSFDCSingleRequest">
<xs:sequence>
<xs:element name="sObjectType" type="xs:string" nillable="false"/>
<xs:element name="fieldUpdates" type="ns1:dataPair" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="createSFDCSingleResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="dataPair">
<xs:sequence>
<xs:element name="fieldName" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1"/>
<xs:element name="value" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="queryCondition">
<xs:sequence>
<xs:element name="queryField" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1"/>
<xs:element name="operator" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1"/>
<xs:element name="value" type="xs:string" nillable="false" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:schema>