Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SoapUI MockServices returning html rather than xml response

Using the following sample WSDL file, I've generated a new project in SOAP UI (version 3.5), and created the example test suite, test case, and mock service.

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>

I can start up the mock service and access via the browser, whereby I see a link to the wsdl and can view it.

However, by using the default generated soap request (as follows), it returns an html response (appears to be the web page) rather than the soap response I have configured.

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>

I've configured a sample response as follows :

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

Its configured as the default response, so I have no idea why it is not being returned.

Any suggestions? +1's to anything that helps me progress this.

Thanks

like image 804
Jimmy Avatar asked Jan 11 '12 19:01

Jimmy


People also ask

What is mock response in SOAPUi?

A mock service imitates a real REST or SOAP API – it contains definitions for operations that clients call, receives requests, and returns simulated responses. Note: In the SoapUI documentation, mocking can also be called isolation, virtualization, or simulation.

Which dispatch method can be implemented for mock service responses?

SEQUENCE: this is the simplest dispatch method; responses are selected and returned in the order they have been added to the MockOperation. RANDOM: almost as simple, this dispatcher selects which response to use at random, over time all responses will have been returned the same number of times.

How can create mock service in SOAPUi without WSDL?

You can just trick SOAPUi with some dummy WSDL, at least with a single request/response definition! Just replace the requests it generates with the XML document you wanted. You an also add additional requests with entirely different request/responses by copy and pasting! Save this answer.


2 Answers

No service is started for the endpoint URL from your request: http://localhost:8088/SayHello/. The only started service is located at URL http://localhost:8088/mockHello_Binding as reported in the service response. SoapUI returns list of all started mock services in HTML page when a non-existed one is requested. Consider fixing endpoint address to resolve this issue.

like image 186
Artem Zankovich Avatar answered Sep 16 '22 19:09

Artem Zankovich


I have hit the same problem using soap ui 5.4.0. It have happend beacuse the path of created mock service was incorrect.

If you click in the soap UI, on the created mock service - properties button on the bottom - you will see that your path looks like /mockBindingservice, it should say /.

To change it, double click on the created mock service, click stop service than settings button (located next to stop and start buttons).Change Path to / and double check host.

Save, start service. Should work now.

I know it is an old post, but hopefully it will help sombody looking for the anwser.

like image 24
autumn_witch Avatar answered Sep 16 '22 19:09

autumn_witch