Page 1 of 1

PHP SOAP

Posted: Mon Jul 09, 2007 3:08 am
by shiznatix
Ok this is my first attempt at using the SOAP extension and so far no go. Basically, this website that I want data from just gives me an XML file and says 'send your request like this'. Now I am not yet knowledgeable enough to tear it apart and know what kind of SOAP call or whatever to make so I am hoping that someone here can help.

Here is the XML file that I need to send (this is all the info they are giving me) SOAP 1.2:

Code: Select all

POST PATH_TO_ASMX_FILE.asmx HTTP/1.1
Host: http://WWW.EXAMPLE.COM
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetPokerStatsMonth xmlns="WEBSERVICES.EXAMPLE.COM/PARTNERS">
      <username>string</username>
      <password>string</password>
      <year>int</year>
      <month>int</month>
    </GetPokerStatsMonth>
  </soap12:Body>
</soap12:Envelope>
the stuff in CAPS is what I took out to protect the innocent but you can see the important stuff. So how do I make that call appropriatly?

Posted: Mon Jul 09, 2007 6:28 am
by volka
try to request PATH_TO_ASMX_FILE.asmx?wsdl in your browser. Do you get somethin like http://www.webservicex.com/CurrencyConvertor.asmx?wsdl ?

Posted: Mon Jul 09, 2007 7:17 am
by harsha
Hi

visit this URL: http://www.urdalen.no/wsdl2php/

this site contains a php script named wsdl2php.php
this command line script reads the wsdl schema and convert the Complex/normal data types in to equivalent php classes.

Posted: Mon Jul 09, 2007 8:05 am
by itsmani1
what you will do is just make an xml request and in response you will get xml response but before this some how you need to get the wsdl file then it will be very easy.

Posted: Mon Jul 09, 2007 8:20 am
by volka
e.g. with php5's soap extension querying the mentioned example service at http://www.webservicex.com/CurrencyConvertor.asmx?wsdl can be as simple as

Code: Select all

<?php
$client = new SoapClient('http://www.webservicex.com/CurrencyConvertor.asmx?wsdl');
$result = $client->ConversionRate(array('FromCurrency'=>'EUR', 'ToCurrency'=>'USD'));
echo $result->ConversionRateResult;