简体   繁体   English

在PHP中创建SOAP请求

[英]Create SOAP request IN PHP

I'm having same SOAP related problem which is posted in 我在发布与SOAP相关的问题 How to create an arbitrary SOAP request using PHP? 如何使用PHP创建任意SOAP请求?

i have used below code.but getting no response. 我用下面的代码。但没有反应。

<?php
$client = new SoapClient('http://www.example.com/services/RecipeCouponAPI11.asmx?wsdl');
$header = new SoapHeader(
    'http://www.example.com/services/',
    'RCAuthenticator',
    array(
        'UserName' => 'username',
        'Password' => 'password'
    )
);

$client->__setSoapHeaders($header);

$response = $client->GetCouponAll(array('campaignCode' => ''));
print_r($response);
?>
POST /cool/update.asmx HTTP/1.1
Host: www.example.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.example.com/COOL/Update/ProductUpdate"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ProductUpdate xmlns="http://www.example.com/COOL/Update">
      <CustomerNumber>12345</CustomerNumber>
      <UserName>12345</UserName>
      <Password>12345</Password>
      <Source>string</Source>
    </ProductUpdate>
  </soap:Body>
</soap:Envelope>

Found solution.I have used wrong function. 找到解决方案。我使用了错误的功能。 It will be 这将是

$response = $client->ProductUpdate(array('campaignCode' => ''));

instead of 代替

$response = $client->GetCouponAll(array('campaignCode' => ''));

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

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