Java SoapUI MockServices返回html而不是xml响应

Java SoapUI MockServices返回html而不是xml响应,java,soap,mocking,soapui,Java,Soap,Mocking,Soapui,使用以下示例WSDL文件,我在SOAPUI(版本3.5)中生成了一个新项目,并创建了示例测试套件、测试用例和模拟服务 WSDL <definitions name="HelloService" targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.

使用以下示例WSDL文件,我在SOAPUI(版本3.5)中生成了一个新项目,并创建了示例测试套件、测试用例和模拟服务

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>

HelloService的WSDL文件
我可以启动模拟服务并通过浏览器进行访问,通过浏览器可以看到指向wsdl的链接并查看它

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

请求

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>
POSThttp://localhost:8088/SayHello/ HTTP/1.1
接受编码:gzip,deflate
内容类型:text/xml;字符集=UTF-8
SOAPAction:“说你好”
用户代理:Jakarta Commons HttpClient/3.1
主机:本地主机:8088
内容长度:467
詹姆斯
响应

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>
HTTP/1.1200正常
内容类型:text/html;字符集=iso-8859-1
传输编码:分块
服务器:Jetty(6.1.x)
目前有1个正在运行soapUI MockServices

我已按如下方式配置了一个示例响应:

模拟的样本响应

<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>

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

有什么建议吗+我愿意做任何有助于我进步的事情


感谢您的请求:
http://localhost:8088/SayHello/
。唯一启动的服务位于URL
http://localhost:8088/mockHello_Binding
如维修响应中所述。当请求一个不存在的模拟服务时,SoapUI返回HTML页面中所有已启动的模拟服务的列表。考虑固定端点地址来解决这个问题。

< P>我与BizTalk 2010发送端口和模拟SOAPUI WebService有类似的问题。 我发现两个URL是不同的 当我在IE中打开它时,我看到了HTML响应。
http://localhost:8088/MockUpdateBasicHttp

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

正确的URL在端口号后面有一个“/”。
http://localhost:8088/MockUpdateBasicHttp

我在使用SOAPUI5.4.0时遇到了同样的问题。发生这种情况是因为创建的模拟服务的路径不正确

如果在soap UI中单击底部的created mock service-properties按钮,您将看到您的路径类似于/mockBindingservice,应该是/

若要更改它,请双击创建的模拟服务,单击“停止服务”而不是“设置”按钮(位于“停止”和“启动”按钮旁边)。更改到/的路径并双击主机

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


我知道这是一篇老文章,但希望它能帮助sombody查找anwser。

您所点击的Url不正确。MockService URL是在您使用默认端口8088将WSDL导入SOAP时创建的。 解决方案: 1) 创建新项目 2) 导入WSDL 3) 选中CreateMockService 4) 然后您将看到运行mockservice的URL::-->mockSearchURL(例如) 5) 点击HTTP://{IP}:8088/mockSearchURL


完成

我认为是Url中的名称和请求中的名称

网址:您好 请求:向S和S问好


名称应该匹配

此处提出的问题相同:出于好奇-您是否能够创建一个简单的Java客户端来调用该web服务并从中获得响应?请完成本教程。很好,你把你的soap版本号和你的答案一起发布了。这样可以保持一点。。。最新;-)先生,你是个传奇人物。我正在使用wireshark,但仍然不知道为什么SOAPUI不能正确响应我的REST请求。事实证明,我需要将路径(在REST MockService选项中)设置为/,并且只需要为模拟操作设置资源路径。以前我把两者都设置为同一件事。