PHP의 SoapClient 클래스를 사용하여 버전 번호만으로 Paypal에 빈 호출을하는 간단한 예제를 얻을 수 있습니까? 올바른 WSDL url과 server url을 가지고 있으므로 도움이 필요하지 않습니다. 이것이 내가 가진 것입니다 :페이팔에 대한 간단한 PHP SoapClient 예제가 필요합니다.
public function SOAPcall($function, $args=array()) {
$args['Version'] = '63.0';
$args = new SoapVar($args, SOAP_ENC_ARRAY, $function.'_Request');
$args = array(new SoapVar($args, SOAP_ENC_ARRAY, $function.'_Req', 'urn:ebay:api:PayPalAPI'));
$results = $this->soapClient->__soapCall($function, $args, array('location' => $this->activeKeys['certificate']), $this->soapOptions);
}
나는 모든 것을 보여줄 수는 없으 리라.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="urn:ebay:api:PayPalAPI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:ebay:apis:eBLBaseComponents">
<SOAP-ENV:Header>
<ns1:RequesterCredentials>
<ns2:Credentials>
<ns2:Username>xxx</ns2:Username>
<ns2:Password>xxx</ns2:Password>
<ns2:Signature>xxx</ns2:Signature>
</ns2:Credentials>
</ns1:RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:GetBalanceReq xsi:type="ns1:GetBalance_Req">
<xsd:string>63.0</xsd:string>
</ns1:GetBalanceReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
그것은 다음과 같아야합니다 :
물론<?xml version=”1.0” encoding=”UTF-8”?>
<SOAP-ENV:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:SOAP-ENC=”http://schemas.xmlsoap.org/soap/encoding/”
xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/”
xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”
><SOAP-ENV:Header>
<RequesterCredentials xmlns=”urn:ebay:api:PayPalAPI”>
<Credentials xmlns=”urn:ebay:apis:eBLBaseComponents”>
<Username>api_username</Username>
<Password>api_password</Password>
<Signature/>
<Subject/>
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<specific_api_name_Req xmlns=”urn:ebay:api:PayPalAPI”>
<specific_api_name_Request>
<Version xmlns=urn:ebay:apis:eBLBaseComponents”>service_version
</Version>
<required_or_optional_fields xsi:type=”some_type_here”> data
</required_or_optional_fields>
</specific_api_name_Request>
</specific_api_name_Req>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
는, 페이팔은 "버전이 지원되지 않습니다"오류가 발생합니다 아래 볼 수있는 요청의 몸은 완전히 잘못 나온다.
이런 일을 끝내게되었습니다. NVP는 구현하기가 쉽지만 SOAP만큼이나 아름답지는 않아요. 결국 SOAP보다 복잡 해지는 경향이 있습니다. – Jonah
SoapVar 클래스 사용에 대한 추론을 설명해 주시겠습니까? 당신은 단지 직선 배열을 전달합니다. – Steven
내 코드에서 남긴 메모에 따르면 요청의이 요소에 형식 정보를 추가하기 위해 형식 및 네임 스페이스 세부 정보를 포함시켜야했습니다. 아마도 여러분이 직선 배열을 전달한다면 타입 정보는 추가되지 않을 것입니다 (?). 원래 응답을 올렸을 때 유형 정보가 포함되어 있지 않으면 서버가 혼동되어 "알 수없는 버전"오류가 발생합니다. 어쩌면 Paypal이이 점에서 서버를 좀 덜 엄격하게 만들려고 무언가를 바꿨을 것입니다. 특히 많은 개발자를 끌어들이는 경우 ... – JamesG