2011-01-27 5 views
0

Ce qui suit est un exemple de requête SOAP 1.1 et la réponseMettre en œuvre SOAP 1.1 en php

POST /DEMOWebServices2.8/service.asmx HTTP/1.1 
Host: api.efxnow.com 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "https://api.efxnow.com/webservices2.3/DealRequestAtBest" 

<?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> 
    <Authenticator xmlns="https://api.efxnow.com/webservices2.3"> 
     <ApplicationName>string</ApplicationName> 
     <IPAddress>string</IPAddress> 
     <UserID>string</UserID> 
     <MachineName>string</MachineName> 
    </Authenticator> 
    </soap:Header> 
    <soap:Body> 
    <DealRequestAtBest xmlns="https://api.efxnow.com/webservices2.3"> 
     <UserID>string</UserID> 
     <PWD>string</PWD> 
     <Pair>string</Pair> 
    </DealRequestAtBest> 
    </soap:Body> 
</soap:Envelope> 

Réponse -

HTTP/1.1 200 OK 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 

<?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:Body> 
    <DealRequestAtBestResponse xmlns="https://api.efxnow.com/webservices2.3"> 
     <DealRequestAtBestResult> 
     <Success>boolean</Success> 
     <ErrorDescription>string</ErrorDescription> 
     <ErrorNumber>int</ErrorNumber> 
     <Confirmation>string</Confirmation> 
     <ConfirmationNumber>string</ConfirmationNumber> 
     <Rate>double</Rate> 
     </DealRequestAtBestResult> 
    </DealRequestAtBestResponse> 
    </soap:Body> 
</soap:Envelope> 

je veux savoir comment faire la demande et comment gérer la réponse si cette a dû être fait en PHP. je lis this mais je ne peux pas comprendre comment serait __setSoapHeaders() et __call() être mis en œuvre dans mon cas. Merci d'avance.

+0

Regardez les tutoriels http://devzone.zend.com/article/689 –

Répondre

1

Il existe une bibliothèque SOAP pour PHP, mais pour un simple échange, vous pouvez envisager de créer un corps de requête XML sous forme de chaîne et de l'envoyer à l'aide de la fonction curl library. C'est une API réseau de plus bas niveau, que je trouve au moins plus facile à utiliser. Notez que PHP doit être compilé --with-curl [= DIR].

<?php 
    $ch = curl_init(); 

    curl_setopt($ch, CURLOPT_URL, $uri); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    if ((bool)$proxy) { 
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Pragma:','Cache-Control:')); 
     curl_setopt($ch, CURLOPT_PROXY, $proxy); 
    } 
    // Apply the XML to our curl call 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data); 

    $out = curl_exec($ch); 
    curl_close($ch); 
?> 
Questions connexes