简体   繁体   中英

Create SOAP request IN PHP

I'm having same SOAP related problem which is posted in How to create an arbitrary SOAP request using PHP?

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' => ''));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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