如何连接到 WSDL 网络服务?
How to connect to WSDL web service?
这是以下 WSDL 网络服务 xml 结构:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. -->
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. -->
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://dispproj/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://dispproj/" name="DipService">
<types>
<xsd:schema>
<xsd:import namespace="http://dispproj/" schemaLocation="http://www.example.com:8888/OfficeSRV/DipPort?xsd=1" />
</xsd:schema>
</types>
<message name="getDisp">
<part name="parameters" element="tns:getDisp" />
</message>
<message name="getDispResponse">
<part name="parameters" element="tns:getDispResponse" />
</message>
<message name="getActiveoffice">
<part name="parameters" element="tns:getActiveoffice" />
</message>
<message name="getActiveofficeResponse">
<part name="parameters" element="tns:getActiveofficeResponse" />
</message>
<portType name="Dip">
<operation name="getDisp">
<input message="tns:getDisp" />
<output message="tns:getDispResponse" />
</operation>
<operation name="getActiveoffice">
<input message="tns:getActiveoffice" />
<output message="tns:getActiveofficeResponse" />
</operation>
</portType>
<binding name="DipPortBinding" type="tns:Dip">
<soap12:binding transport="http://www.w3.org/2003/05/soap/bindings/HTTP/" style="document" />
<operation name="getDisp">
<soap12:operation soapAction="" />
<input>
<soap12:body use="literal" />
</input>
<output>
<soap12:body use="literal" />
</output>
</operation>
<operation name="getActiveoffice">
<soap12:operation soapAction="" />
<input>
<soap12:body use="literal" />
</input>
<output>
<soap12:body use="literal" />
</output>
</operation>
</binding>
<service name="DipService">
<port name="DipPort" binding="tns:DipPortBinding">
<soap12:address location="http://www.example.com:8888/OfficeSRV/DipPort" />
</port>
</service>
</definitions>
架构如下:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://dispproj/" version="1.0" targetNamespace="http://dispproj/">
<xs:element name="getActiveoffice" type="tns:getActiveoffice" />
<xs:element name="getActiveofficeResponse" type="tns:getActiveofficeResponse" />
<xs:element name="getDisp" type="tns:getDisp" />
<xs:element name="getDispResponse" type="tns:getDispResponse" />
<xs:complexType name="getDisp">
<xs:sequence>
<xs:element name="arg0" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="getDispResponse">
<xs:sequence>
<xs:element name="return" type="tns:disp" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="disp">
<xs:sequence>
<xs:element name="disps" type="xs:anyType" nillable="true" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="getActiveoffice">
<xs:sequence />
</xs:complexType>
<xs:complexType name="getActiveofficeResponse">
<xs:sequence>
<xs:element name="return" type="tns:activeOffices" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="activeOffices">
<xs:sequence>
<xs:element name="offADDRESS" type="xs:string" minOccurs="0" />
<xs:element name="offEMAIL" type="xs:string" minOccurs="0" />
<xs:element name="offFAX" type="xs:string" minOccurs="0" />
<xs:element name="offLIECENE" type="xs:string" minOccurs="0" />
<xs:element name="offMobile" type="xs:string" minOccurs="0" />
<xs:element name="offPHONE" type="xs:string" minOccurs="0" />
<xs:element name="offid" type="xs:int" />
<xs:element name="offname" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:schema>
我正在为 Chrome 使用 Postman(它是 http request/response 客户端):
请求URL:http://www.example.com:8888/OfficeSRV/DipPort
请求Body(我在body测试后了解到:http://tomi.vanek.sk/index.php?page=wsdl-viewer):
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://dispproj/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<mns1:getActiveoffice xmlns:mns1="http://dispproj/" />
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
在线 WSDL 客户端成功检索到结果,但是当我尝试使用 Postman 请求的 url 和 body 时,我遇到了以下问题:
415: Unsupported Media Type
我的请求中是否缺少某些 HTTP 请求 headers?
经过多次尝试,我发现我必须提供以下 HTTP 请求 Header:
Content-Type -> Content-Type: application/soap+xml;charset=UTF-8
我通过使用 SoapUI 发现了这一点
这是以下 WSDL 网络服务 xml 结构:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. -->
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. -->
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://dispproj/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://dispproj/" name="DipService">
<types>
<xsd:schema>
<xsd:import namespace="http://dispproj/" schemaLocation="http://www.example.com:8888/OfficeSRV/DipPort?xsd=1" />
</xsd:schema>
</types>
<message name="getDisp">
<part name="parameters" element="tns:getDisp" />
</message>
<message name="getDispResponse">
<part name="parameters" element="tns:getDispResponse" />
</message>
<message name="getActiveoffice">
<part name="parameters" element="tns:getActiveoffice" />
</message>
<message name="getActiveofficeResponse">
<part name="parameters" element="tns:getActiveofficeResponse" />
</message>
<portType name="Dip">
<operation name="getDisp">
<input message="tns:getDisp" />
<output message="tns:getDispResponse" />
</operation>
<operation name="getActiveoffice">
<input message="tns:getActiveoffice" />
<output message="tns:getActiveofficeResponse" />
</operation>
</portType>
<binding name="DipPortBinding" type="tns:Dip">
<soap12:binding transport="http://www.w3.org/2003/05/soap/bindings/HTTP/" style="document" />
<operation name="getDisp">
<soap12:operation soapAction="" />
<input>
<soap12:body use="literal" />
</input>
<output>
<soap12:body use="literal" />
</output>
</operation>
<operation name="getActiveoffice">
<soap12:operation soapAction="" />
<input>
<soap12:body use="literal" />
</input>
<output>
<soap12:body use="literal" />
</output>
</operation>
</binding>
<service name="DipService">
<port name="DipPort" binding="tns:DipPortBinding">
<soap12:address location="http://www.example.com:8888/OfficeSRV/DipPort" />
</port>
</service>
</definitions>
架构如下:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5. -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://dispproj/" version="1.0" targetNamespace="http://dispproj/">
<xs:element name="getActiveoffice" type="tns:getActiveoffice" />
<xs:element name="getActiveofficeResponse" type="tns:getActiveofficeResponse" />
<xs:element name="getDisp" type="tns:getDisp" />
<xs:element name="getDispResponse" type="tns:getDispResponse" />
<xs:complexType name="getDisp">
<xs:sequence>
<xs:element name="arg0" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="getDispResponse">
<xs:sequence>
<xs:element name="return" type="tns:disp" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="disp">
<xs:sequence>
<xs:element name="disps" type="xs:anyType" nillable="true" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="getActiveoffice">
<xs:sequence />
</xs:complexType>
<xs:complexType name="getActiveofficeResponse">
<xs:sequence>
<xs:element name="return" type="tns:activeOffices" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="activeOffices">
<xs:sequence>
<xs:element name="offADDRESS" type="xs:string" minOccurs="0" />
<xs:element name="offEMAIL" type="xs:string" minOccurs="0" />
<xs:element name="offFAX" type="xs:string" minOccurs="0" />
<xs:element name="offLIECENE" type="xs:string" minOccurs="0" />
<xs:element name="offMobile" type="xs:string" minOccurs="0" />
<xs:element name="offPHONE" type="xs:string" minOccurs="0" />
<xs:element name="offid" type="xs:int" />
<xs:element name="offname" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:schema>
我正在为 Chrome 使用 Postman(它是 http request/response 客户端):
请求URL:http://www.example.com:8888/OfficeSRV/DipPort
请求Body(我在body测试后了解到:http://tomi.vanek.sk/index.php?page=wsdl-viewer):
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://dispproj/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<mns1:getActiveoffice xmlns:mns1="http://dispproj/" />
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
在线 WSDL 客户端成功检索到结果,但是当我尝试使用 Postman 请求的 url 和 body 时,我遇到了以下问题:
415: Unsupported Media Type
我的请求中是否缺少某些 HTTP 请求 headers?
经过多次尝试,我发现我必须提供以下 HTTP 请求 Header:
Content-Type -> Content-Type: application/soap+xml;charset=UTF-8
我通过使用 SoapUI 发现了这一点