2012-01-11 90 views
7

使用下面的示例WSDL文件,我在SOAP UI(版本3.5)中生成了一个新项目,并创建了示例测试套件,测试用例和模拟服务。SoapUI MockServices返回html而不是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> 

我可以启动通过浏览器,由此我看到一个链接到WSDL并可以查看它的模拟服务和访问。

但是,通过使用默认生成的soap请求(如下所示),它会返回一个html响应(看起来是网页)而不是我配置的soap响应。

REQUEST

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> 

RESPONSE

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> 

我如下构成的示例响应:

样本响应ON 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> 

它配置为默认响应,所以我不知道为什么它没有被返回。

有什么建议吗? +1对任何有助于我进步的东西。

感谢

+0

同样的问题在这里问:http://www.soapui.org/forum/viewtopic.php?t=4177 – Jimmy 2012-01-11 19:49:55

+0

出于好奇 - 你能够创建一个简单的Java客户端,调用该Web服务并获得响应从中? – 2012-01-11 20:13:57

回答

10

没有任何服务正在开始从您的请求的端点URL:http://localhost:8088/SayHello/。唯一启动的服务位于服务响应中报告的URL http://localhost:8088/mockHello_Binding。当请求一个不存在的模拟服务时,SoapUI返回HTML页面中所有已启动的模拟服务的列表。考虑修复端点地址以解决此问题。

-1

我有与BizTalk 2010发送端口和模拟SOAPUI webservice类似的问题。 我发现这2个URL不同 当我在IE中打开这个..我看到了HTML响应。 http://localhost:8088/MockUpdateBasicHttp

当你在IE中打开它时,我得到了一个空白的白色屏幕,通常意味着成功。 http://localhost:8088//MockUpdateBasicHttp

正确的URL在端口号后带有一个'/'。 http://localhost:8088/MockUpdateBasicHttp

1

我使用soap ui 5.4.0时遇到了同样的问题。它已经发生,因为创建的模拟服务的路径不正确。

如果你点击soap UI,在底部创建的模拟服务 - 属性按钮 - 你会看到你的路径看起来像/ mockBindingservice,它应该说/。

要更改它,请双击创建的模拟服务,单击停止服务而不是设置按钮(位于停止和开始按钮旁边)。更改路径到/并重复检查主机。

保存,启动服务。现在应该工作。

我知道这是一个旧帖子,但希望它会帮助sombody寻找anwser。

+0

请完成参观。很好,你发布了你的肥皂版本号和你的答案。这样它保持了一点...最新;-) – ZF007 2018-01-17 10:25:14

0

您打的网址不正确。而导入的WSDL到SOAP默认端口MockService URL创建8088 解决方法: 1)新建项目 2)进口WSDL 3)检查创建Mockervice 4)然后你会看到的网址,让mockservice将运行:: - > mockSearchURL(例如) 5)hit HTTP://{IP}:8088/mockSearchURL

DONE !!