Sử dụng tệp WSDL mẫu sau, tôi đã tạo một dự án mới trong giao diện người dùng SOAP (phiên bản 3.5) và tạo bộ thử mẫu, trường hợp thử nghiệm và dịch vụ mô phỏng.SoapUI MockServices trả về html thay vì phản hồi xml
WSDL
<definitions name="HelloService"
targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="SayHelloRequest">
<part name="firstName" type="xsd:string"/>
</message>
<message name="SayHelloResponse">
<part name="greeting" type="xsd:string"/>
</message>
<portType name="Hello_PortType">
<operation name="sayHello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>
<binding name="Hello_Binding" type="tns:Hello_PortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sayHello">
<soap:operation soapAction="sayHello"/>
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</output>
</operation>
</binding>
<service name="Hello_Service">
<documentation>WSDL File for HelloService</documentation>
<port binding="tns:Hello_Binding" name="Hello_Port">
<soap:address
location="http://www.examples.com/SayHello/"/>
</port>
</service>
</definitions>
tôi có thể khởi động các dịch vụ giả và truy cập thông qua trình duyệt, nhờ đó mà tôi nhìn thấy một liên kết đến wsdl và có thể xem nó.
Tuy nhiên, bằng cách sử dụng yêu cầu xà phòng được tạo mặc định (như sau), nó trả về phản hồi html (dường như là trang web) thay vì phản hồi xà phòng mà tôi đã định cấu hình.
YÊU CẦU
POST http://localhost:8088/SayHello/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "sayHello"
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8088
Content-Length: 467
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:examples:helloservice">
<soapenv:Header/>
<soapenv:Body>
<urn:sayHello soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<firstName xsi:type="xsd:string">James</firstName>
</urn:sayHello>
</soapenv:Body>
</soapenv:Envelope>
ỨNG PHÓ
HTTP/1.1 200 OK
Content-Type: text/html; charset=iso-8859-1
Transfer-Encoding: chunked
Server: Jetty(6.1.x)
<html><body><p>There are currently 1 running soapUI MockServices</p><ul><li><a href="/mockHello_Binding?WSDL">Hello_Binding MockService</a></li></ul></p></body></html>
Tôi đã cấu hình một phản ứng mẫu như sau:
MẪU phản ứng trên Mock
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:examples:helloservice">
<soapenv:Header/>
<soapenv:Body>
<urn:sayHelloResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<greeting xsi:type="xsd:string">?</greeting>
</urn:sayHelloResponse>
</soapenv:Body>
</soapenv:Envelope>
Được định cấu hình làm phản hồi mặc định, vì vậy tôi không biết tại sao nó không được trả lại.
Mọi đề xuất? +1 cho bất cứ điều gì giúp tôi tiến bộ điều này.
Cảm ơn
Vấn đề tương tự được yêu cầu tại đây: http://www.soapui.org/forum/viewtopic.php?t=4177 – Jimmy
Hết sức tò mò - Bạn có thể tạo một máy khách Java đơn giản gọi dịch vụ web đó và nhận phản hồi hay không từ nó? –