0
PHP에서 wsdl을 사용하여 SOAP API에 요청 데이터를 보내려면 도움이 필요합니다. 나는 PHP를위한 soapclient 확장을 설치했고 잘 동작하고있다.wsdl이있는 PHP SOAP 요청이 작동하지 않습니다. "SOAP-ERROR : 인코딩 : 객체에 'phoneNumber'속성이 없습니다."
<?php
$client = new SoapClient($wsdlUrl, array('username' => USER_NAME, 'password' => PASSWORD,'trace'=>'1','exception'=>0));
$method = "templateSMS";
$xmlr = new SimpleXMLElement("<Sms></Sms>");
$xmlr->addChild("phoneNumber",PHONE_NUMBER);
$xmlr->addChild('message', 'Hi how are you');
$xmlr->addChild('unicodeMessage', 0);
$xmlr->addChild('sms_type_id', 1);
$xmlr->addChild('senderId', SENDER_ID);
$xmlr->addChild('notify', 0);
$xmlr->addChild('priority', 1);
$xmlr->addChild('vbApp', 'SoapRequest');
$xmlr->addChild('vbIdTime', time());
$params = new stdClass();
$params->xml = $xmlr->asXML();
try {
$data = $client->$method($params);
var_dump($data);
}catch (SoapFault $e) {
echo "<pre> Exceptions Break :";
print_r($e);
echo "</pre>";
}
?>
내가 브라우저에서 위의 코드 실행이 나에게 오류를 제공 "SOAP-ERROR : 인코딩 : 오브젝트가 'PHONENUMBER'속성이 없습니다"여기
을 오류 로그입니다 여기에 스크립트입니다
Exceptions Break :SoapFault Object
(
[message:protected] => SOAP-ERROR: Encoding: object has no 'phoneNumber' property
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => C:\xampp\htdocs\soapDemo\opt3.php
[line:protected] => 18
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => C:\xampp\htdocs\soapDemo\opt3.php
[line] => 18
[function] => __call
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => templateSMS
[1] => Array
(
[0] => stdClass Object
(
[xml] =>
Hi how are you0101SoapRequest1480835353
)
)
)
)
[1] => Array
(
[file] => C:\xampp\htdocs\soapDemo\opt3.php
[line] => 18
[function] => templateSMS
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => stdClass Object
(
[xml] =>
Hi how are you0101SoapRequest1480835353
)
)
)
)
[previous:Exception:private] =>
[faultstring] => SOAP-ERROR: Encoding: object has no 'phoneNumber' property
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
)
지원 팀이 나에게 요구 포맷을 통과 할 수있는 샘플 XML 코드를 제공하고 여기에 샘플 XML 요청 형식이 요청은 다음과 같이 동일해야이다 :, 내 문제를 해결하기 위해 더 helpfull이 될 수 있습니다
,<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:templateSMS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:ElbaridTNS" xmlns:ns3="namespace" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<ns3:AuthHeader>
<username>username </username>
<password>password</password>
</ns3:AuthHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:templateSMS>
<Sms xsi:type="ns2:Sms"><phoneNumber xsi:type="xsd:string">xxxxxx</phoneNumber>
<message xsi:type="xsd:string">test SMS </message>
<unicodeMessage xsi:type="xsd:string">test SMS</unicodeMessage>
<sms_type_id xsi:type="xsd:string">1</sms_type_id>
<notify xsi:type="xsd:string">0</notify>
<senderId xsi:type="xsd:string">SenderId</senderId>
<priority xsi:type="xsd:string">2</priority>
<vbApp xsi:type="xsd:string">SoapRequest</vbApp>
<vbIdTime xsi:type="xsd:string">20161130101112</vbIdTime>
<destinationPort xsi:type="xsd:string">-1</destinationPort></Sms>
</ns1:templateSMS>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
응답은 다음과 같이해야합니다 :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:templateSMS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:templateSMSResponse>
<templateSMSResponse xsi:type="xsd:string">0#!#200#!#http://198.101.210.203/Soap/service/elbarid|http://212.98.137.180/Soap/service/elbarid#!#SenderId </templateSMSResponse>
</ns1:templateSMSResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
사람이 내 문제를 해결하기 위해 나를 도와 줄 수
? 나는 또한 CURL로 시도하지만 같은 오류가 발생한다.감사 :
감사를 호출하지만 여전히 내가 같은 오류가 점점 오전 : SOAP-ERROR : 인코딩 : 객체가 더 'PHONENUMBER'속성이를 – JGandhi