简体   繁体   English

如何创建肥皂客户端

[英]How to create a soap client

I'm really ameteur to coding php and soap. 我真的很想编码php和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. 我想请求此服务: http : //www.artimesaj.com/services/artimesaj.asmx?op=TekMesajCokNumara,但我不知道该怎么做。 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"

First, you construct a SOAPClient object , passing in the URL for the machine-readable service description (WSDL) : 首先, 构造一个SOAPClient对象 ,传入用于机器可读服务描述(WSDL)的URL:

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

Then you need to add the "SOAP header" for the <securty> part: 然后,您需要为<securty>部分添加“ SOAP标头”:

$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 , eg TekMesajCokNumara : 然后,您可以调用服务中定义的“操作”(功能)之一 ,例如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; 然后,SOAP库会将所有参数转换为适当的XML,将其发送到服务(使用与您的问题类似的请求)并给您响应。 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. 以我的经验,使SOAP正确交互可能有点麻烦,而且我绝对不能保证上述代码可以正常工作,或保证可以帮助您调试它,但是希望它提供了您应使用的那种代码的示例期望写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM