Work on this for a week. Failed to execute this code. I want to get data through SOAP and work with it in PHP. My problem is that I am having trouble sending "RequesterCredentials".
I will show the xml code so that you can see the information I'm trying to send, and then the PHP code that I use.
XML SAMPLE CODE
POST /AuctionService.asmx HTTP/1.1 Host: apiv2.gunbroker.com Content-Type: text/xml; charset=utf-8 Content-Length: 200 SOAPAction: "GunBrokerAPI_V2/GetItem" <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> <RequesterCredentials xmlns="GunBrokerAPI_V2"> <DevKey>devkey</DevKey> <AppKey>appkey</AppKey> </RequesterCredentials> </soap:Header> <soap:Body> <GetItem xmlns="GunBrokerAPI_V2"> <GetItemRequest> <ItemID>312007942</ItemID> <ItemDetail>Std</ItemDetail> </GetItemRequest> </GetItem>
The php code I use to create the call
$client = new SoapClient("http://apiv2.gunbroker.com/AuctionService.asmx?WSDL"); $appkey = 'XXXXXX-XXXXXX-XXXXXX'; $devkey = 'XXXXXX-XXXXXX-XXXXXX'; $header = new SoapHeader('GunBrokerAPI_V2','RequesterCredentials',array('DevKey' => $devkey,'AppKey' => $appkey),0); $client->__setSoapHeaders(array($header)); $result = $client->GetItem('312343077'); echo '<pre>',print_r($result,true),'</pre>';
RESULT OBTAINED
stdClass Object ( [GetItemResult] => stdClass Object ( [Timestamp] => 2012-11-07T18:17:31.9032903-05:00 [Ack] => Failure [Errors] => stdClass Object ( [ShortMessage] => GunBrokerAPI_V2 Error Message : [GetItem] You must fill in the 'RequesterCredentialsValue' SOAP header for this Web Service method. [ErrorCode] => 1 )
I'm not sure if the problem is how Im sending SoapHeaders or I don't understand the syntax. I would really appreciate any help.
source share