PHP SOAP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

PHP SOAP

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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 ?
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

Post 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.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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;
Post Reply