Help with SOAP request using PHP
Posted
by mptre
on Stack Overflow
See other posts from Stack Overflow
or by mptre
Published on 2010-04-16T14:14:44Z
Indexed on
2010/04/17
18:23 UTC
Read the original article
Hit count: 409
I'm having a SOAP related problem in PHP. I'm trying to create arbitrary SOAP request using Nusoap_client class. The complete request including headers should look like the example below. Ofcourse the placeholders (string) should be replaced with actual values.
POST /services/RecipeCouponAPI11.asmx HTTP/1.1
Host: example.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.example.com/services/GetCouponAll"
<?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:Header>
<RCAuthenticator xmlns="http://www.example.com/services/">
<UserName>string</UserName>
<Password>string</Password>
</RCAuthenticator>
</soap:Header>
<soap:Body>
<GetCouponAll xmlns="http://www.example.com/services/">
<campaignCode>string</campaignCode>
</GetCouponAll>
</soap:Body>
</soap:Envelope>
I tried the following code with no luck. Seems like the request isn't formated correctly. Any ideas on how to get his working?
<?php
$client = new Nusoap_client('http://www.example.com/services/RecipeCouponAPI11.asmx');
$headers = new SoapHeader(
'http://www.example.com/services/',
'RCAuthenticator',
(object)array(
'UserName' => 'username',
'Password' => 'password'
),
false
);
$client->setHeaders(array($headers));
$response = $client->call(
'GetCouponAll',
array('campaignCode' => 'campaigncode'),
null,
'http://www.example.com/services/GetCouponAll'
);
?>
Thanks in advantage!
© Stack Overflow or respective owner