Przyznaje, ze jestem raczej zielony w zagadnieniach XML. Moj problem polega na tym, ze chce wyciagnac konkretna wartosc z pliku XML i nie do konca jestem zadowolony z rezultatu.
To jest wzorzec odwolania do webservice:
CODE
POST /tracking.asmx HTTP/1.1
Host: adreswebservice.domena.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.domena.com/GetAffiliateGroupRevenueByUniqueId"
<?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>
<GetAffiliateGroupRevenueByUniqueId xmlns="http://domena.com/">
<strUniqueId>string</strUniqueId>
</GetAffiliateGroupRevenueByUniqueId>
</soap:Body>
</soap:Envelope>
To jest odpowiedz webservice:
CODE
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>
<GetAffiliateGroupRevenueByUniqueIdResponse xmlns="http://domena.com">
<GetAffiliateGroupRevenueByUniqueIdResult>
<intReturnCode>int</intReturnCode>
<strReturnMessage>string</strReturnMessage>
<intLeadId>int</intLeadId>
<strExpressConsent>string</strExpressConsent>
<strFindBrokerRequestGUID>string</strFindBrokerRequestGUID>
<dblLeadCost>double</dblLeadCost>
</GetAffiliateGroupRevenueByUniqueIdResult>
</GetAffiliateGroupRevenueByUniqueIdResponse>
</soap:Body>
</soap:Envelope>
A to kod, ktorym dysponuje na chwile obecna. Chcialbym jednak wyciagnac tylko wartosc leada

function callWS() { $host = "adreswebservice.domena.com"; $port = 80; $uri = "http://adreswebservice.domenacom/tracking.asmx"; $affid = $_GET['affid']; //Host and port must be set here! $fp = fsockopen($host, $port, $errno, $errstr, 30); if (!$fp) { $a["errorstring"] = $errstr; $a["errno"] = $errno; return $a; } else { // creating the response message with headers $out = "POST $uri HTTP/1.1\r\n"; $out .= "Host: ".$_SERVER['SERVER_NAME']."\r\n"; $out .= "Connection: Close\r\n"; //Content must be assembled here because of the Content-Length HTTP header. $content = '<?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> <GetAffiliateGroupRevenueByUniqueId xmlns="http://domena.com/"> <strUniqueId>'.$affid.'</strUniqueId> </GetAffiliateGroupRevenueByUniqueId> </soap:Body> </soap:Envelope>'; $out .= "Content-Type: text/xml; charset=utf-8\r\n"; $out .= "Content-Length: ". strlen($content)."\r\n\r\n"; $out .= $content; fwrite($fp, $out); //Retrieving response message $response = ""; while (!feof($fp)) { $response .= fgets($fp, 128); } fclose($fp); //echo "**".$response."**"; //checking if we've got back intReturnCode. If not, we will handle the response as an error response. if (strpos($response,"<intReturnCode>") != FALSE) { $intReturnCode = substr($response,strpos($response,"<intReturnCode>")+100, strpos($response,"</intReturnCode>")-2-strpos($response,"<intReturnCode>")-14 ); $strReturnMessage = substr($response,strpos($response,"<strReturnMessage>")+249, strpos($response,"</strReturnMessage>")-20-strpos($response,"<strReturnMessage>")-24); $a["intReturnCode"] = $intReturnCode; $a["strReturnMessage"] = $strReturnMessage; } else { $a["errno"] = 777; $a["errorstring"] = "No intReturnCode provided in the response XML data."; $a["strReturnMessage"] = substr($response,strpos($response,"<strReturnMessage>")+18, strpos($response,"</strReturnMessage>")-1-strpos($response,"<strReturnMessage>")-17); } //print $response; return $a; } } //Example function call $e = callWS(); //Example data processing with basic error checking. if (!isset($e["errno"])) { echo $e["intReturnCode"]; echo "Your earnings are: <b>"; echo $e["strReturnMessage"]; echo "</b>"; } else { echo $e["errno"]." - ". $e["errorstring"]; } ?>
Oczywiscie za pomoca normalnego formularza przekazuje zmienna $affid. Bylbym wdzieczny za jakies sugestie. Dzieki.
Naprawde nikt nie jest w stanie dac jakiejs odpowiedzi?