Hakan SONMEZ
Hakan SONMEZ

Reputation: 2226

How to create a soap client

I'm really ameteur to coding php and soap. I want to do request for this service: http://www.artimesaj.com/services/artimesaj.asmx?op=TekMesajCokNumara but I don't know how to do. I don't understand anything this site.

Finally what is this? What should I do these:

  POST /services/artimesaj.asmx HTTP/1.1
  Host: www.artimesaj.com
  Content-Type: text/xml; charset=utf-8
  Content-Length: length
  SOAPAction: "http://tempuri.org/TekMesajCokNumara"

Upvotes: 0

Views: 62

Answers (1)

IMSoP
IMSoP

Reputation: 97638

First, you construct a SOAPClient object, passing in the URL for the machine-readable service description (WSDL):

$client = new SOAPClient('http://www.artimesaj.com/services/artimesaj.asmx?WSDL');

Then you need to add the "SOAP header" for the <securty> part:

$header = new SoapHeader(
     'http://tempuri.org/', 
     'securty',
     array(
         'KullaniciAdi' => '???',
         'Parola' => '???',
         'Orijin' => '???'
     )
);
$client->__setSoapHeaders($header);

Then you can make a call to one of the defined "operations" (functions) in the service, e.g. TekMesajCokNumara:

$response = $client->TekMesajCokNumara(array(
     'message' => '???',
     'numbers' => array(
        'TelefonNo' => array(
           'TelNo' => '???'
        ),
        'TelefonNo' => array(
           'TelNo' => '???'
        )
      ),
      'date' => '???'
));

The SOAP library will then turn all your parameters into the appropriate XML, send it to the service (using a request like the one in your question) and give you the response; if all goes well, you don't need to know what any of that means, it will just work.

Obviously, you need to find some documentation of what those arguments should actually be.

In my experience, getting SOAP to interact right can be a bit fiddly, and I make absolutely no guarantees that the above code will just work, or promises to help you debug it, but hopefully it gives an example of the kind of code you should be expecting to write.

Upvotes: 1

Related Questions