1

I am working on a webservice project where the client wants to send a complex type request to the server. We are using PHP at server and jQuery Mobile as the client.

Below is the type of SOAP request the client is sending. The client is sending 2 argument. The first argument is a string 'doLoginValidation' and the second argument is a list of parameters (key and value)

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <callServer>
      <methodName>doLoginValidation</methodName>
      <parameters>
        <parameter>
          <key>url</key>
          <value>value</value>
        </parameter>
        <parameter>
          <key>username</key>
          <value>malaiselvan</value>
        </parameter>
        <parameter>
          <key>password</key>
          <value>123456</value>
        </parameter>
      </parameters>
    </callServer>
  </soap:Body>
</soap:Envelope>

I am trying to build the WSDL and got stuck on configuring the arguments. Find below the partial WSDL file

<types>
  <xsd:complexType name="parameterList">
    <xsd:sequence>
      <xsd:element name="key" type="xsd:string"/>
      <xsd:element name="value" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:element name="parameters">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="unbounded" minOccurs="0" name="parameter" nillable="true" type="tns:parameterList"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</types>

<message name='callServerRequest'> 
  <part name='methodname' type='xsd:string'/> 
  <part name='parameters' type='xsd:parameters'/> 
</message>
<message name='callServerResponse'> 
  <part name='response' type='xsd:string'/>
</message> 

<portType name='websitePortType'> 
  <operation name='callServer'> 
    <input message='tns:callServerRequest'/> 
    <output message='tns:callServerResponse'/> 
  </operation>
</portType>

Question 1: How to setup the methodname and parameters in the WSDL file?

Find below the PHP program

<?php 

function callServer($methoName, $parmeters) { 

  //how to get the parameters sent from the client

  return "some value";
}

ini_set("soap.wsdl_cache_enabled", "0"); 
$server = new SoapServer("smsmobile.wsdl"); 
$server->addFunction("callServer"); 

$server->handle(); 

?>

Question 2: How to receive the values sent from client inside the PHP program?

Malaiselvan
  • 1,153
  • 1
  • 16
  • 42
  • I might misunderstand you, but are you really planning to use a Soap service with Javascript? That sounds like a bad idea for any use case, but especially for a mobile app. – Sven Dec 05 '13 at 21:56
  • @Sven - We are binding everything finally into a PhoneGap android application. We spent a lot of time on the design and finally come up this as a best approach – Malaiselvan Dec 05 '13 at 21:59
  • 1
    You would use `xsd` to define complex types. See [this](http://stackoverflow.com/questions/1437015/how-can-i-embed-complex-types-into-wsdl-definition) and [this](http://stackoverflow.com/questions/19456126/how-to-define-wsdl-complex-type-for-soap-response-with-list-of-items) – Wrikken Dec 05 '13 at 22:23
  • .. and is set up correctly, your data would just be in your `$parmeters` (sic) variable. – Wrikken Dec 05 '13 at 22:25
  • 1
    I doubt it can be the best approach if no one on the team knows how to create a WSDL - which in the end will be useless anyway because the Javascript client will never use it to create requests. – Sven Dec 05 '13 at 22:38
  • @Wrikken - Thanks. I edited my question by adding the complex type. But in my PHP file I receive the methodName but not the parameters. Any idea? Is there any problem in the complex type? – Malaiselvan Dec 05 '13 at 22:58
  • Hm, `name="result"` seems off on that one. Isn't the element called `parameter`? – Wrikken Dec 05 '13 at 23:05
  • @Wrikken - I dont understand what is the significance of `name="result"`. I changed that to `name="parameter"` and also tried with `name="parameters"` both doesn't work. – Malaiselvan Dec 05 '13 at 23:13

0 Answers0