当我尝试将我的WSDL导入Salesforce并从中生成APEX代码时,我遇到了一个问题。问题是针对Salesforce,但我的一般性问题与Salesforce无关,因为我认为我的问题有一个通用的解决方案。当我在以下文件中向我的第二个架构添加targetnamespace(Salesforce中需要)时,我需要更新引用,以便我的请求仍具有有效格式:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wss="http://www.boomi.com/connector/wss">
<soapenv:Header/>
<soapenv:Body>
<wss:querySearch>
<!--Optional:-->
<Car>
<Reg_Number></Reg_Number>
</Car>
</wss:querySearch>
</soapenv:Body>
</soapenv:Envelope>
我目前的WSDL:
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.boomi.com/connector/wss" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="WebServiceProvider" targetNamespace="http://www.boomi.com/connector/wss" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.boomi.com/connector/wss" version="1.0">
<xs:import />
<xs:element name="querySearch" type="tns:querySearch" />
<xs:complexType name="querySearch">
<xs:sequence>
<xs:element minOccurs="0" ref="Car" />
</xs:sequence>
</xs:complexType>
<xs:element name="querySearchResponse" type="tns:querySearchResponse" />
<xs:complexType name="querySearchResponse">
<xs:sequence>
<xs:element minOccurs="0" ref="Car" />
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema elementFormDefault="qualified" version="1.0">
<xs:element name="Car" type="Car" />
<xs:complexType name="Car">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="Reg_Number" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="querySearch">
<wsdl:part name="parameters" element="tns:querySearch" />
</wsdl:message>
<wsdl:message name="querySearchResponse">
<wsdl:part name="parameters" element="tns:querySearchResponse" />
</wsdl:message>
<wsdl:portType name="WebServiceProviderPortType">
<wsdl:operation name="querySearch">
<wsdl:input message="tns:querySearch" />
<wsdl:output message="tns:querySearchResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WebServiceProviderPortBinding" type="tns:WebServiceProviderPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="querySearch">
<soap:operation soapAction="querySearch" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WebServiceProvider">
<wsdl:port name="WebServiceProviderPort" binding="tns:WebServiceProviderPortBinding">
<soap:address location="XXXXXXXX" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
当我将WSDL更改为以下内容时(添加一个targetnamespace并将&#34; tns:&#34;添加到类型中):
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.boomi.com/connector/wss" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="WebServiceProvider" targetNamespace="http://www.boomi.com/connector/wss">
<wsdl:types>
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.boomi.com/connector/wss" version="1.0">
<xs:element name="Car" type="tns:Car"/>
<xs:complexType name="Car">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="Reg_Number" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="querySearch" type="tns:querySearch"/>
<xs:complexType name="querySearch">
<xs:sequence>
<xs:element minOccurs="0" ref="tns:Car"/>
</xs:sequence>
</xs:complexType>
<xs:element name="querySearchResponse" type="tns:querySearchResponse"/>
<xs:complexType name="querySearchResponse">
<xs:sequence>
<xs:element minOccurs="0" ref="tns:Car"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="querySearch">
<wsdl:part element="tns:querySearch" name="parameters"/>
</wsdl:message>
<wsdl:message name="querySearchResponse">
<wsdl:part element="tns:querySearchResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="WebServiceProviderPortType">
<wsdl:operation name="querySearch">
<wsdl:input message="tns:querySearch"/>
<wsdl:output message="tns:querySearchResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WebServiceProviderPortBinding" type="tns:WebServiceProviderPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="querySearch">
<soap:operation soapAction="querySearch"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WebServiceProvider">
<wsdl:port binding="tns:WebServiceProviderPortBinding" name="WebServiceProviderPort">
<soap:address location="XXXXXXXXXXXXXXXXX"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
它通过Salesforce但生成以下请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wss="http://www.boomi.com/connector/wss">
<soapenv:Header/>
<soapenv:Body>
<wss:querySearch>
<!--Optional:-->
<wss:Car>
<wss:Reg_Number>?</wss:Reg_Number>
</wss:Car>
</wss:querySearch>
</soapenv:Body>
</soapenv:Envelope>
它增加了&#34; wss&#34;请求中Car元素和输入参数的前缀,这使请求无效。我可以通过更改名称空间或类似的东西以某种方式解决这个问题吗? wsdl是从Dell Boomi生成的,因此可以优先考虑解决方案,但是现在我很满意,如果我可以手动更改WSDL。
侨!
答案 0 :(得分:0)
elementFormDefault="qualified"
表示您想获得前缀。尝试使用值unqualified
来自http://www.w3schools.com/schema/el_schema.asp:
elementFormDefault:可选。在此架构的目标命名空间中声明的元素的表单。该值必须为“合格”或“不合格”。默认为“不合格”。 “unqualified”表示目标名称空间中的元素不需要使用名称空间前缀进行限定。 “qualified”表示目标命名空间中的元素必须使用命名空间前缀
进行限定