четвер, 28 січня 2016 р.

How to test SOAP service

1. click soap service
2. create war file and deploy to Tomcat
3. test by SoapUI
create project and input wsdl file
message should be sent for testing soap service. For testing rest service URI should be send



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="http://impl/">
   <soapenv:Header/>
   <soapenv:Body>
      <impl:add>
         <arg0>10</arg0>
         <arg1>10</arg1>
      </impl:add>
   </soapenv:Body>
</soapenv:Envelope>

and the respond will be message too

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:addResponse xmlns:ns2="http://impl/">
         <return>20</return>
      </ns2:addResponse>
   </soap:Body>
</soap:Envelope>

4. test by using client
create another project

public class CalcClient {

    public static void main(String[] args) {

        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

        factory.setServiceClass(ICalculator.class);
        factory.setAddress("http://localhost:8080/SOAPCalculator/soap?wsdl");
        factory.getInInterceptors().add(new LoggingInInterceptor());
        factory.getOutInterceptors().add(new LoggingOutInterceptor());
        ICalculator client = (ICalculator) factory.create();
        Add request = new Add();
     
        request.setArg0(1);
        request.setArg1(10);
   
        int reply = client.add(request.getArg0(), request.getArg1());          
     
        AddResponse response = new AddResponse();
   
        response.setReturn(reply);
        System.out.println("Response: "+ response.getReturn());
    }

}


Немає коментарів:

Дописати коментар