Mohse Taheri
Mohse Taheri

Reputation: 741

how to generate XML request of SOAP webservice like SOAPUI request with PHP

I want to create an application with PHP that get WSDL and method name from user and generate a SOAP request just like SOAPUI.

in fact I want to create application just like SOAPUI that create XML request and let user edit it and fill the requested parameters.

how could I do that?

Upvotes: 2

Views: 1611

Answers (2)

Mohse Taheri
Mohse Taheri

Reputation: 741

I found a solution :)

as far as I know there is no PHP equivalent for SOAPUI. so I found that there is a API in SOAPUI with help of @satheesh-cheveri in following link, and create JAVA program to use it and then call the JAVA application inside my PHP application:

https://stackoverflow.com/a/20487079/1665693

I take a long time to find out what library needed to be imported so I list it here for everyone who needed:

  • apache-httpcomponents-httpclient.jar
  • apache-httpcomponents-httpcore.jar
  • apache-xml-xerces.jar
  • bcprov-jdk15-144.jar
  • commons-beanutils-1.7.0.jar
  • commons-cli-1.3.1.jar
  • commons-logging-1.1.jar
  • junit-4.4.jar
  • log4j-1.2.8.jar
  • rsyntaxtextarea-1.4.1.jar
  • soapui-4.5.0.jar
  • soapui-xmlbeans-4.5.0.jar
  • wsdl4j-1.6.2-fixed.jar
  • xbean-fixed-2.4.0.jar

and here is my function I asked for:

public String generateSampleRequest(String wsdl, String method) {
    String result = "";
    try {
        WsdlProject project = new WsdlProject();
        WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, wsdl);
        WsdlInterface ws = wsdls[0];
        WsdlOperation wsdlOperation = ws.getOperationByName(method);
        result = wsdlOperation.createRequest(true);
        ws.release();
        project.release();
    } catch (Exception e) {
        result = e.getMessage();
    }
    return result;
}

Upvotes: 2

matiaslauriti
matiaslauriti

Reputation: 8082

You are looking for SoapServer. More info here.


EDIT I forgot to add SoapClient. Thanks Magnus Eriksson

Upvotes: 1

Related Questions