在我的场景中,有一个在 WSO2-AS 中运行的 Web 服务“SolverDummyWS”,并希望在 WSO2 ESB 中为该服务生成一个代理。
因此,我手动为代理创建了一个 wsdl,并添加了一些必需的标头字段。所以只有代理的 wsdl 应该有这个头。标头都应该是强制性的,并定义为 EXPLICIT HEADERS。
Proxy-WSDL 如下所示:
<wsdl:definitions name="SolverDummyProxy"
targetNamespace="http://de.unistuttgart.iaas" xmlns:tns="http://de.unistuttgart.iaas"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<schema targetNamespace="http://de.unistuttgart.iaas"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="createGrid">
<complexType>
<sequence>
<element minOccurs="0" name="milliseconds" type="long" />
</sequence>
</complexType>
</element>
<element name="createGridResponse">
<complexType>
<sequence>
<element minOccurs="0" name="return" type="string" />
</sequence>
</complexType>
</element>
<element name="requestHeader">
<complexType>
<sequence>
<element minOccurs="1" name="simulationId" type="long" />
<element minOccurs="1" name="activityId" type="long" />
<element minOccurs="1" name="requiredPolicy" type="anyType" />
<element minOccurs="1" name="requiredPortType" type="string" />
<element minOccurs="1" name="requiredScope" type="anyURI" />
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="createGridRequest">
<wsdl:part name="body" element="tns:createGrid" />
<wsdl:part name="reqHeader" element="tns:requestHeader" />
</wsdl:message>
<wsdl:message name="createGridResponse">
<wsdl:part name="body" element="tns:createGridResponse" />
</wsdl:message>
<wsdl:portType name="SolverDummyProxyWSPortType">
<wsdl:operation name="createGrid">
<wsdl:input message="tns:createGridRequest" />
<wsdl:output message="tns:createGridResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SolverDummyProxyWSSoap11Binding" type="tns:SolverDummyProxyWSPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="createGrid">
<wsdl:input>
<soap:body parts="body" use="literal" />
<soap:header message="tns:createGridRequest" part="reqHeader"
use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body parts="body" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="SolverDummyProxyWSSoap12Binding" type="tns:SolverDummyProxyWSPortType">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="createGrid">
<wsdl:input>
<soap12:body parts="body" use="literal" />
<soap12:header message="tns:createGridRequest" part="reqHeader"
use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body parts="body" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SolverDummyProxyWS">
<wsdl:port name="SolverDummyProxyWSSoap11Endpoint" binding="tns:SolverDummyProxyWSSoap11Binding">
<soap:address location="http://localhost:8280/services/SolverDummyProxyWS.SolverDummyProxyWSSoap11Endpoint" />
</wsdl:port>
<wsdl:port name="SolverDummyProxyWSSoap12Endpoint" binding="tns:SolverDummyProxyWSSoap12Binding">
<soap12:address location="http://localhost:8280/services/SolverDummyProxyWS.SolverDummyProxyWSSoap12Endpoint" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
所以我使用 WSO2-ESB Web 界面创建了一个代理。如果我查看所创建代理的实际 WSDL,我会发现 WSO2-ESB 做了一些更改: - 添加了 HTTP 绑定 - 从 createGridRequest 消息中删除了标头部分 - 混乱的 soap:input 绑定(有两个标头定义,并且身体部分被移除)
由 WSO2-ESB 修改的 WSDL
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:tns="http://de.unistuttgart.iaas" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://de.unistuttgart.iaas">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://de.unistuttgart.iaas">
<element name="createGrid">
<complexType>
<sequence>
<element minOccurs="0" name="milliseconds" type="long" />
</sequence>
</complexType>
</element>
<element name="createGridResponse">
<complexType>
<sequence>
<element minOccurs="0" name="return" type="string" />
</sequence>
</complexType>
</element>
<element name="requestHeader">
<complexType>
<sequence>
<element name="simulationId" type="long" />
<element name="activityId" type="long" />
<element name="requiredPolicy" type="anyType" />
<element name="requiredPortType" type="string" />
<element name="requiredScope" type="anyURI" />
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="createGridRequest">
<wsdl:part name="body" element="tns:createGrid" />
</wsdl:message>
<wsdl:message name="createGridResponse">
<wsdl:part name="body" element="tns:createGridResponse" />
</wsdl:message>
<wsdl:portType name="SolverDummyProxyHWSPortType">
<wsdl:operation name="createGrid">
<wsdl:input message="tns:createGridRequest" wsaw:Action="http://de.unistuttgart.iaas/SolverDummyProxyWSPortType/createGridRequest" />
<wsdl:output message="tns:createGridResponse" wsaw:Action="http://de.unistuttgart.iaas/SolverDummyProxyWSPortType/createGridResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SolverDummyProxyHWSSoap11Binding" type="tns:SolverDummyProxyHWSPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="createGrid">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap12:header use="literal" part="reqHeader" message="tns:createGridRequest" />
<soap12:header use="literal" part="reqHeader" message="tns:createGridRequest" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="SolverDummyProxyHWSSoap12Binding" type="tns:SolverDummyProxyHWSPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="createGrid">
<soap12:operation soapAction="" style="document" />
<wsdl:input>
<soap12:body use="literal" />
<soap12:header use="literal" part="reqHeader" message="tns:createGridRequest" />
<soap12:header use="literal" part="reqHeader" message="tns:createGridRequest" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="SolverDummyProxyHWSHttpBinding" type="tns:SolverDummyProxyHWSPortType">
<http:binding verb="POST" />
<wsdl:operation name="createGrid">
<http:operation location="createGrid" />
<wsdl:input>
<mime:content type="text/xml" part="parameters" />
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="parameters" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SolverDummyProxyHWS">
<wsdl:port name="SolverDummyProxyHWSHttpSoap11Endpoint" binding="tns:SolverDummyProxyHWSSoap11Binding">
<soap:address location="http://Tobiass-MacBook-Pro.local:8280/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpSoap11Endpoint" />
</wsdl:port>
<wsdl:port name="SolverDummyProxyHWSHttpsSoap11Endpoint" binding="tns:SolverDummyProxyHWSSoap11Binding">
<soap:address location="https://Tobiass-MacBook-Pro.local:8243/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpsSoap11Endpoint" />
</wsdl:port>
<wsdl:port name="SolverDummyProxyHWSHttpSoap12Endpoint" binding="tns:SolverDummyProxyHWSSoap12Binding">
<soap12:address location="http://Tobiass-MacBook-Pro.local:8280/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpSoap12Endpoint" />
</wsdl:port>
<wsdl:port name="SolverDummyProxyHWSHttpsSoap12Endpoint" binding="tns:SolverDummyProxyHWSSoap12Binding">
<soap12:address location="https://Tobiass-MacBook-Pro.local:8243/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpsSoap12Endpoint" />
</wsdl:port>
<wsdl:port name="SolverDummyProxyHWSHttpsEndpoint" binding="tns:SolverDummyProxyHWSHttpBinding">
<http:address location="https://Tobiass-MacBook-Pro.local:8243/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpsEndpoint" />
</wsdl:port>
<wsdl:port name="SolverDummyProxyHWSHttpEndpoint" binding="tns:SolverDummyProxyHWSHttpBinding">
<http:address location="http://Tobiass-MacBook-Pro.local:8280/services/SolverDummyProxyHWS.SolverDummyProxyHWSHttpEndpoint" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
此代码没有强制标头,因此我创建初始标头的最初目的被 wso2-esb 搞砸了。
有人可以告诉我如何将强制标头添加到代理服务(如果我的初始 wsdl 文件有错误,就会出现这种情况)?
如果我最初的 wsdl 文件没问题,我怎么能强制 wso2-esb 使用这个文件,并且不修改它?!?
最后一个问题,对于对代理的请求,是否有另一种创建强制标头的方法?
感谢您的回答!