Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>This is what you need to do.</h2> <p>Just to know, I tried to recreate your situation...</p> <hr> <ul> <li>For this example, I made a .NET sample webservice with a <code>WebMethod</code> called <code>Function1</code> and these are the parameters: </li> </ul> <blockquote> <p>Function1(Contact Contact, string description, int amount)</p> </blockquote> <ul> <li><p>In which <code>Contact</code> is just a bean <code>class</code> that has getters and setters for <code>id</code> and <code>name</code> like in your case.</p></li> <li><p>You can download this .NET sample webservice at:</p></li> </ul> <p><a href="https://www.dropbox.com/s/6pz1w94a52o5xah/11593623.zip">https://www.dropbox.com/s/6pz1w94a52o5xah/11593623.zip</a></p> <hr> <h2>The code.</h2> <p>This is what you need to do at <strong>PHP</strong> side:</p> <p><em>(Tested and working)</em></p> <pre><code>&lt;?php /* Create a class for your webservice structure, in this case: Contact */ class Contact { function Contact($id, $name) { $this-&gt;id = $id; $this-&gt;name = $name; } } /* Initialize webservice with your WSDL */ $client = new SoapClient("http://localhost:10139/Service1.asmx?wsdl"); /* Fill your Contact Object */ $contact = new Contact(100, "John"); /* Set your parameters for the request */ $params = array( "Contact" =&gt; $contact, "description" =&gt; "Barrel of Oil", "amount" =&gt; 500, ); /* Invoke webservice method with your parameters, in this case: Function1 */ $response = $client-&gt;__soapCall("Function1", array($params)); /* Print webservice response */ var_dump($response); ?&gt; </code></pre> <hr> <h2>How I know this is working?</h2> <ul> <li>If you do <code>print_r($params);</code> you will see this output, as your webservice expects:</li> </ul> <blockquote> <p>Array ( [Contact] => Contact Object ( [id] => 100 [name] => John ) [description] => Barrel of Oil [amount] => 500 )</p> </blockquote> <ul> <li>When I debugged the sample .NET webservice I got this:</li> </ul> <p><img src="https://i.stack.imgur.com/hDwTT.jpg" alt="enter image description here"></p> <p><em>(As you can see, <code>Contact</code> object is not null and also other parameters, that means your request was successfully done from PHP side).</em> </p> <ul> <li>The response from .NET sample webservice was the expected one and shown at PHP side:</li> </ul> <blockquote> <p>object(stdClass)[3] public 'Function1Result' => string 'Detailed information of your request! id: 100, name: John, description: Barrel of Oil, amount: 500' (length=98)</p> </blockquote> <hr> <p>Hope this helps :-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload