1
PHP에서 SOAP 관련 문제가 있습니다. Nusoap_client 클래스를 사용하여 임의의 SOAP 요청을 작성하려고합니다. 헤더를 포함한 전체 요청은 아래 예와 같아야합니다. 물론 자리 표시 자 (문자열)는 실제 값으로 대체해야합니다.PHP를 사용하여 임의의 SOAP 요청을 만드는 방법은 무엇입니까?
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>
나는 다음과 같은 PHP 코드를 사용해 보았습니다. 요청이 올바르게 형식이 지정되지 않은 것 같습니다. 그의 일하는 방법에 대한 아이디어가 있습니까?
<?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'
);
?>