Fun with SOAP.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A fellow co-worker of mine is working on a project integrating with
Amazon using SOAP.  I've never used SOAP before but it seemed like
things were straight forward at first.  Some parts work while others
done.  Right now we are stuck trying to fetch a document from the
remote server.

We are able to connect and get a list of documents as expected.  The
PHP 5 SOAP extension handles this like a champ.  When a single
document is requested an exception is thrown with the error message
"looks like we got no XML document."  The document listing request
returns a simple single text/xml SOAP XML response.  The request for a
single document returns a multi-part (multipart/related) response.

Can the PHP 5 soap client even parse such things?  I looked at the
manual pages and did Google searching, but I'm not even sure what to
word my queries as.  It seems like somehow this should just work as
the script just defines a client and then does the call.  So any help
or links to something that explains how this multipart response can be
handled will be greatly appreciated.  See below for the script &
responses.


Here is the sample script:
($params and $merchant are defined)
$client = new SoapClient('https://merchant-api.amazon.com/gateway/merchant-interface-mime',$params);
try {
    $doc = $client->getDocument($merchant, 575326853);
} catch(SoapFault $fault) {
    var_dump($fault);
}




Here are the raw headers:
HTTP/1.1 200
Date: Tue, 29 Apr 2008 19:33:18 GMT
Server: Server
EmbeddedSOAPServer: WASP-C++ Vespa/4.6, build 2162 (Linux i686
2.6.18-8.el5a2xen #1 SMP Tue Apr 3 16:48:05 PDT 2007)
MIME-Version: 1.0
nnCoection: close
Transfer-Encoding: chunked
Content-Type: multipart/related;
boundary="xxx-WASP-CPP-MIME-Boundary-xxx-0x9eeb578-09eeb578-xxx-END-xxx";
type="text/xml"

Here is the raw XML response from the Amazon server:
--xxx-WASP-CPP-MIME-Boundary-xxx-0x9eeb578-09eeb578-xxx-END-xxx
Content-Type: text/xml; charset="UTF-8"

<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:SE="http://schemas.xmlsoap.org/soap/encoding/";><SOAP-ENV:Body><ns0:string_Response
xsi:type="xsd:string"
xmlns:ns0="http://systinet.com/xsd/SchemaTypes/";>575326853</ns0:string_Response><ns1:doc
href="cid:0xaff0940-0xb1ebe40-0xb06d3f0-0xb22d500-0xb1ec630"
xmlns:ns1="http://systinet.com/xsd/SchemaTypes/"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
--xxx-WASP-CPP-MIME-Boundary-xxx-0x9eeb578-09eeb578-xxx-END-xxx
Content-ID: <0xaff0940-0xb1ebe40-0xb06d3f0-0xb22d500-0xb1ec630>
Content-Type: application/binary

<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>...</MerchantIdentifier>
</Header>
<MessageType>OrderReport</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderReport>
<AmazonOrderID>...</AmazonOrderID>
<AmazonSessionID>...</AmazonSessionID>
<OrderDate>...</OrderDate>
<OrderPostedDate>...</OrderPostedDate>
<BillingData>
<BuyerEmailAddress>...</BuyerEmailAddress>
<BuyerName>...</BuyerName>
<BuyerPhoneNumber>...</BuyerPhoneNumber>
</BillingData>
<FulfillmentData>
<FulfillmentMethod>...</FulfillmentMethod>
<FulfillmentServiceLevel>...</FulfillmentServiceLevel>
<Address>
<Name>...</Name>
<AddressFieldOne>...</AddressFieldOne>
<City>...</City>
<StateOrRegion>...</StateOrRegion>
<PostalCode>...</PostalCode>
<CountryCode>...</CountryCode>
<PhoneNumber>...</PhoneNumber>
</Address>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>...</AmazonOrderItemCode>
<SKU>...</SKU>
<Title>...</Title>
<Quantity>...</Quantity>
<ProductTaxCode>...</ProductTaxCode>
<ItemPrice>
<Component>
<Type>...</Type>
<Amount currency="USD">...</Amount>
</Component>
<Component>
<Type>Shipping</Type>
<Amount currency="USD">...</Amount>
</Component>
<Component>
<Type>Tax</Type>
<Amount currency="USD">...</Amount>
</Component>
<Component>
<Type>ShippingTax</Type>
<Amount currency="USD">...</Amount>
</Component>
</ItemPrice>
<ItemFees>
<Fee>
<Type>Commission</Type>
<Amount currency="USD">...</Amount>
</Fee>
</ItemFees>
</Item>
</OrderReport>
</Message>
</AmazonEnvelope>

--xxx-WASP-CPP-MIME-Boundary-xxx-0x9eeb578-09eeb578-xxx-END-xxx--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux