Simple PHP SOAP example

This post will show a simple example of how to interpretate a WSDL file and a very simple, yet quick example of how to extract information from this file through PHP.

Prior assumptions

In this example I assume that you've already have SOAP enabled in your PHP configuration because this is beyond the scope of this example. If you're not sure, you can check your phpinfo file. There should be something like this:

SOAP information

SOAP information

Example WSDL file

For the example WSDL file we'll take this WSDL file. It's about the World Championship football 2010 held in South Africa.

Analyzing the WSDL file

Let's analyze this file for a simple method we can call. I usually work with Notepad++ or Smultron. The following line number apply to Notepad++ and probably also to Smulton.

Let's try and print the top goal scorers of the tournament. For doing this, we can see the following on line 1295 - 1300:

<operation name="TopGoalScorers">
  <documentation>
Returns an array with the top N goal scorers and their current score. Pass 0 as TopN and you get them all.
  </documentation>
  <input message="tns:TopGoalScorersSoapRequest"/>
  <output message="tns:TopGoalScorersSoapResponse"/>
</operation>

We now see that the operation we should call is called TopGoalScorers. This operation expects as input a TopGoalScorersSoapRequest. We don't know what it is yet, so let's find out. If we search the document for this message, we get to line 999 - 1002 which says:

<message name="TopGoalScorersSoapRequest">
  <part name="parameters" element="tns:TopGoalScorers" />
</message>

Right. So now we know that the TopGoalScorersSoapRequest consists of just one part (the parameters). We know that the element is called TopGoalScorers, but we do not know anything about this parameter yet. So we search the document for the element TopGoalScorers. We can find this element at line 384 - 390. These lines say

<xs:element name="TopGoalScorers">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="iTopN" type="xs:int" />
    </xs:sequence>
  </xs:complexType>
</xs:element>

Now there we have it: we now finally know that the method TopGoalScorers which we saw in the first WSDL fragment expects one parameter as input. This parameter is called iTopN and is of the type int.

Getting to the code

Finally we can do something with the WSDL. Actually we can do this in a very short way thanks to the PHP SoapClient!

Calling the service with the parameter and obtaining the results can be done in just 2 lines of code. Let's give it a try and obtain the top 5 goal scorers. We can do this by the following two lines:

$client = new SoapClient("http://footballpool.dataaccess.eu/data/info.wso?wsdl");
$result = $client->TopGoalScorers(array('iTopN'=>5));

Note that we use the information we obtained from the WSDL file here: on the $client object, we call the method TopGoalScorers and provide an array of parameters. In this case the array contains only one parameter: the iTopN parameter with an int value of 5.

The result will contain an object, so you will need to traverse the object structure.

Choose how much results

There are a lot of possibilities for abstracting such a Web Service call further. I will just give a very simple example file where you can choose how many results you want to see and visualize this in a table.

Code:

<?php

if ($_POST['topn'] > 0 && (int) $_POST['topn'] <= 20){
  $topn = (int) $_POST['topn'];
  $client = new SoapClient("http://footballpool.dataaccess.eu/data/info.wso?wsdl");
  $result = $client->TopGoalScorers(array('iTopN' => $topn));
  // Note that $array contains the result of the traversed object structure
  $array = $result->TopGoalScorersResult->tTopGoalScorer;

  print "
    <table border='2'>
      <tr>
        <th>Rank</th>
        <th>Name</th>
        <th>Goals</th>
      </tr>
  ";
  
  foreach($array as $k=>$v){
    print "
      <tr>
        <td align='right'>" . ($k+1) . "</td>
          <td>" . $v->sName . "</td>
          <td align='right'>" . $v->iGoals . "</td>
        </tr>";
  }
  
  print "</table>";
}
else {

?>

  <form id="topscorers" action="index.php" method="post">
    How long should your topscorers list be? (Choose a digit between 1 and 20).
    <input id="topn" name="topn" size="2" type="text" value="10" />
    <input id="submit" name="submit" type="submit" value="submit" />
  </form>

<?php

}

?>

Note that the form calls index.php. This is because I called this script index.php. If you call your script differently, the action should be your script file name. (The reason why I didn't use $_SERVER['PHP_SELF'] is because of this Dutch source about how this element can cause an XSS problem).

I hope you found the example useful. If not, let me know! Now go and play with PHP, SOAP and WSDL some more!

Edit 11/08/2010: Noticed that the WSDL was removed. Changed to WC 2010 WSDL file which seems to have the same format as the original WSDL.

Be Sociable, Share!

172 comments

  1. asad says:

    this is great work done but i want to work on it do send me example of the code that you use

  2. Vanessa B says:

    Thanks this help me a lot…. you’re great

  3. Webchemie says:

    Patrick, thanks for this simple and clear example!

  4. Vanessa says:

    This code is great…. You’ve done a really good job

  5. andrew says:

    is this a drupal site?

  6. Patrick says:

    Andrew,

    This is not a Drupal site, but just a WordPress site.

    People who didn’t notice it yet and read asad’s comment: this is all the code there is!

  7. Lan says:

    Patrick,
    Thank you so much.

    If you can also provide the XML message in HTTP for Soap request and Soap response, that would be better. Maybe I’m somewhat lazy, because I can do it by myself. : -)

    Anyway, your simple example helps me a lot…

  8. Patrick says:

    Hi Lan,

    These messages are all handled by the PHP Soapclient. Most languages already provide you with such classes / libraries. E.g. for Python you have SoapPy and Soaplib.

  9. Douwe says:

    Excellent example! Helped me a lot

  10. Joseph says:

    Thank you very much!
    Finally I have found an example that is clear and understandable.

    Best wishes

  11. ADAM says:

    Hi Patrick,
    It is a good example, Could you please mail in my email ID. I need your help for implementing SOAP-PHP.
    Please email me.
    Thank you
    ADAM

  12. Patrick says:

    ADAM,

    Perhaps it’s more useful to discuss such things here. This way more people can benefit from the knowledge..

    Patrick

  13. GS says:

    Hi Patrick,

    Can you please guide me regarding how to use soap headers for sending user credentials in php. I am getting “Invalid Credentials Error” soap protocol with faultcode as soap-server. Don’t know how to fix it please help me out in this if possible.

    Thanks
    GS

  14. Patrick says:

    Hi GS,

    An example SOAP message containing user credentials can be found here.
    Which programming language do you use? This post shows that .NET may put an anchor in the message, which results in an Invalid Credentials Error.

    Hopefully this can be of help. If not, please let me know.

    Regards,

    Patrick

  15. Wilbo says:

    Great tut, very clear – only I can’t get it to work!
    Soap is intalled on the server, the wsdl file is still there, but when I run the script I just get the old Cannot Display the Webpage message
    Any ideas?

  16. Patrick says:

    Wilbo,

    I’ve added the source file here.
    On my machine it works with this script.. (php_soap should be enabled of course).

  17. Tomas says:

    Hello, If I start index.php evrithing is ok and I write a long of top list and click on submit then it write: Fatal error: Class ‘SoapClient’ not found in W:\docs\SOAP\index.php on line 14. Where I have to define class SoapClient.

    Thanks for your answer.

  18. Patrick says:

    Hi Tomas,

    SoapClient is a php extension which can be enabled in the php (ini) config of the web server.

  19. Cybufex says:

    Thanks to this post I was able to determine that the problem I had had nothing to do with my programming skills but rather everything to do with the STUPID ISA server our company uses.

    Thanks for your post.

  20. Ayaz Pasha says:

    Hi Patrick, I will have to pass the soap request via proxy server. Unfortunately I don’t know PHP, can you let me know how can I have this code working for having a proxy server.

  21. Ayaz Pasha says:

    Any idea? Still stuck with the same issue from past 2 days. Any comment regarding this issue will be of greater help.

  22. Ayaz Pasha says:

    Finally got it to work.

    $client = new SoapClient(“http://someaddress?WSDL”, array(‘proxy_host’ => “example.proxy.com”,’proxy_port’ => portnumber));

  23. Patrick says:

    Hi Ayaz,

    I just saw your remarks from this morning. I thought that you were running a proxy server yourself. I misunderstood your actual question.
    Thanks for posting this information anyway!

  24. Ayaz Pasha says:

    Thnks Patrick, I have another issue now, while I was using apache I was able to successfully get this code working and result was being displayed but now I installed & configured IIS for PHP, henceforth I am getting an empty result for this code (there are no any fatal errors though). Any help?

    Sorry if I am posting something that is out of scope for this blog.

  25. Patrick says:

    Ayaz,

    Are all required modules present? I don’t have any experience with IIS I must admit.
    If there aren’t any errors or warnings debugging is pretty hard. Can you actually run other PHP scripts which generate output?
    Does the server log itself say anything which could be of use?

  26. Ayaz Pasha says:

    Patrick,

    My team mate installed a new version of PHP & it worked all fine again, thanks for help. You are right, may be some modules were not enabled(like soap client).

    Thnks for the help, this blog helped me a lot.

  27. amolk says:

    :) nice sample code … thank you

  28. Deep C says:

    Simple and Awesome !!!! …. Thanks :)

  29. MockY says:

    Simple and to the point. SOAP demystified. Thanks.

  30. etangle says:

    excellent job… its awsome… ;-)

  31. Jen says:

    I cannot get this to work .. i’m hoping you can help once i hit the client call i get nothing after that i.e. (stops my script, blank page) …
    https://www.marionzoological.com/fedEx/track/index.php

  32. Patrick says:

    Hi Jen,

    Does your php error_log tell you anything? The page is completely blank. When I look at the page source, it’s also completely blank. Seems like an error is occurring before the output is started.

    Patrick

  33. Jen says:

    are you saying to enable error logging and have it log to a file… im on a vps with plesk 8.6 and i’ve seen some posts about problems with plesk and soap. that being said, this is my first time around trying to implement a web service, so i think i’ll just stick my nose back into chapter 18 (SOAP) of pro php and xml services for now to ensure i am taking the right steps…

    Thanks!

  34. Patrick says:

    I also use a Plesk VPS and it was preconfigured to log to a file. When developing in PHP, it is always advised to use the error logging ;-)

  35. Kiran says:

    Hi Patrick,

    I am implementing soap php. I can able to call your wsdl file. But my client has given one wsdl url. In that client has defined custom types. I dont know how to pass custom type argument. Can you give a sample example.

    HOw will I call sopaclient function

  36. Patrick says:

    Hi Kiran,

    My apologies for my late response. Can you give an example what such a custom type looks like? I assume such a custom type consists of ‘basic’ types like string or int. In that case you should perform and extra operation to put together such a custom type and then pass it as a parameter.

    Kind regards,

    Patrick

  37. qill says:

    Hi Patrick,

    I’ve tried your code, and i works perfectly… Well i’m new about web service, so I’ve a question.

    in your code :
    $client = new SoapClient(“http://footballpool.dataaccess.eu/data/info.wso?wsdl”)

    but when I changed it to :
    require_once(‘nusoap-0.9.5/lib/nusoap.php’);
    $client = new nusoap_client(“http://footballpool.dataaccess.eu/data/info.wso?wsdl”);

    it shows an error. So what’s the diference ? I usually use nusoap for learn about web service.

    Sorry for the newbie question..
    thanks

  38. Patrick says:

    Hi qill,

    Everyone’s gotta start somewhere ;)
    What does the error tell you? Did you check the php error_log for any more details regarding the error? And are you using a kind of custom class?
    I did a little search on nusoap examples and all the hits I got use the same lines as the SoapClient example shown above:

    $client = new soapclient($wsdl, true);

    instead of

    $client = new nusoap_client($wsdl);

    Cheers,

    Patrick

  39. qill says:

    the error is “Fatal error: Call to undefined method nusoap_client::TopGoalScorers() in C:\xampp\htdocs\ws_2\fbtopscorer.php on line 18″

    I use new version of nusoap for study about web service (nusoap-0.9.5)
    And yes.. some example they use $client = new soapclient($wsdl, true);
    but when I try it, it showed an error…

    but when I try $client = new nusoap_client($wsdl);, it works…so I started to use it to create new client object…
    my guess is maybe it because I use it in localhost (not connect in Internet)? is that true ???

    my second question is, I use your code to display all coaches. (http://footballpool.dataaccess.eu/data/info.wso?op=Coaches)

    It works, but I want to display their team info too.. can you help me ??

  40. Patrick says:

    Hi qill,

    You can use it from your localhost as long as you’re running a proper LAMP/WAMP/MAMP stack with the right extensions.
    You connect to the remote wsdl file, right?
    Which team info do you actually want to display? There is a team info tag nested in the coaches result. This can be accessed directly from the results you get back from the SOAP call. If you want other data to be displayed you probably need to do this in more than one step.

    Was this helpful for you?

    Cheers,

    Patrick

  41. qill says:

    Yes…I connect to the remote wsdl… thanks, that makes sense…

    When we invoke coaches function, it return coaches name and team info tag nested (like you mention above)… and I realise that the result will be return as an array.

    but I’m not sure how to manipulate the result in order to display the team info (because it nested)…can you show me the code if I want to show like :
    maradona | argentina | argentina’s flag | argentina url
    capello | england | england’s flag | england url

    it’s just about array manipulation right ???

  42. Patrick says:

    Yes, it’s just about array manipulation.
    If you look at line 8 of the last code fragment you can see that you can also traverse the results in a way.

    Suppose that $result in this case is the CoachesResult you get from your soap client call.
    You can do $result->CoachesResult->tCoaches to get the coaches
    if you take $v as a tCoaches object, you can access the TeamInfo by getting $v->TeamInfo.

    For directly accessing the team info you can use $result->CoachesResult->tCoaches->TeamInfo

    Hope this helps!
    Cheers,

    Patrick

  43. qill says:

    great…that works… thanks patrick

  44. nosebleed says:

    Hey, I have a question. How do you connect actually to the database to get the results? Thanks.

  45. Patrick says:

    Hi nosebleed,

    Do you mean at the server side? The WSDL file does nothing more than denote the remote method that’s called and the data format that will be returned.
    Basically the client’s calling a remote method. That method runs at the server, connects to its database and returns the data (in the format the WSDL describes). There’s nothing different than normal to it.

    Hopefully that answers your question. If not, please reply.

    Cheers,

    Patrick

  46. ali says:

    I created a service using wsdl. I am passing two parameters to my port. but second parameter has no effect could any body tell me why??

  47. Anthony says:

    Its nice job,
    Thanks,

    Is anyone knows how to make a soap server, like a creating a web service and wsdl file according to that?

    then anyone can send request by soap client..

  48. Chaitanya says:

    SOAP CONCEPTS.

  49. Pete says:

    Hey great example, works out of the box. Thanks very much (edited the latter part, Patrick)

  50. AtReyU says:

    Rocking, thanks so much, this has helped me a ton. Had to teach myself how to use SOAP today and you made that very possible.

  51. This code is not woking for me or may it is taking too much time. Because I didnot see any display for this code. Please help in this regard.

    Thanks,
    Regards,
    Ihsanullah

  52. Patrick says:

    Ihsanullah,

    Is there any output? Have you checked the error_log for messages? This could help you solve the problem faster.

    Cheers,

    Patrick

  53. Stephan says:

    Thanks, works great :-)

  54. baljit says:

    great work

  55. Farooq says:

    Hi Patrick,
    here is a link to wsdl file i want to know if we can make calls through this wsdl file as it seems different from the one which you used..
    here is the link: http://ic2.infousa.com/InfoConnect2/2011.04.01/Description/BusinessProcess/WSDL/FlatBusinessProcessServiceType.wsdl

    Will be waiting for your response,

    Thank you.

    Farooq

  56. Patrick says:

    Hi Farooq,

    The file indeed is not structurally 100% the same. There’s some more puzzling involved. Let’s take an example:

    WSDL part

    In this case we have an element ‘operation name’, which is LookupNAICSDetails. It’s kind of the same structure as I mentioned above. You see the documentation tag (which is not filled in, so that’s of no use), but also the the input structure, the structure you get back and also which structure(s) will be returned when an error occurs.
    So you need to put in a structure called IBusinessProcess_LookupNAICSDetails_InputMessage and you get back an IBusinessProcess_LookupNAICSDetails_OutputMessage. The structure of these messages can be found in the WSDL as well.

    Hope this helps you!
    Cheers,

    Patrick

  57. Judhisthira says:

    Hi,

    Thanks,.I am new to SOAP-PHP.
    I not getting the things..I have a class(Wether) in server who has method named ReturnTodayWeather.I have the wsdl file in server for the Wether class.How i will call the web service using WSDL. in client website.

    Kindly give a test mail from your mail id.
    I need your help very badly to implement SOAP service.

    Thanks,
    Judhisthira
    [removed e-mailaddress to reduce spam]

  58. Vishnu says:

    Hi Patrick,
    Heartfelt thanks for the great article. I particularly liked your lucid methodology.
    I am from Java background and have started using PHP for using Drupal (i.e customizing it).
    I was able to refer a PHP soap example.http://pastebin.com/W9uqssMm.
    This works perfectly.
    But for a web service i need to hit -an https link https://freeway.demo.lionbridge.com/vojo/FreewayAuth.asmx?wsdl i have been struggling
    to get it running.
    This wsdl file has a “Logon” method which when passed the Username and password will return me a ticket to be used for the user session.

    I am able to hit the web service method via PHP but it returns me a “User invalid error” instead of the ticket thrown by the source
    hosting the web service.
    I am able to obtain the required ticket when i use Eclipse via Java and its web client option.
    So the only difference there is that i have all the stubs and skeletons i.e. the dependencies auto created by eclipse in java;
    when used with java owing to which i am able to call the method appropriately

    Would like to know ifthere is a way to have the set of dependencies generated for a PHP based approach for consuming a web service.

    Thanks & Regards
    Vishnu S

  59. Patrick says:

    Judhisthira,

    You have the WSDL file, so you know the location, right? I would start off with:
    $wsdlfile = ;
    $client = new SoapClient($wsdlfile);

    That should initialize the soapclient. From there on you should be able to do method calls.
    If you still encounter difficulties, please explain your problem more thoroughly.

    Cheers,

    Patrick

  60. Patrick says:

    Hi Vishnu,

    That’s an interesting one! Are you sure the right information is received by the web service? Seeing the error, it seems like the dispatching method does its job, but doesn’t get the right information. Is it possible to check server sided if the parameters are received in good order? It could have something to do with how data is sent. This could be different in Eclipse than it is when doing directly via PHP.
    As long as the SoapClient is working it should be okay. I haven’t came across dependencies on other packages.
    Hope this points you in the right direction. If not, please tell me.

    Cheers,

    Patrick

  61. Shahriar says:

    Thanks, great article for beginners.

  62. Casper says:

    Why don’t you just use ?

    Then the filename can be everything.

  63. M ZUBAIR says:

    good work! very helpful, thanks alot

  64. Mehul says:

    Hello Patrick,

    Wonderful Article. I am working on a project which requires authentication to access the operations. Can you please provide me the utility used to do the same in php?

  65. derjanni says:

    Nice article. I did a tutorial with NuSOAP in PHP in German as well … maybe someone’s interested in it: http://www.kammerath.net/php-und-soap.html

    Best regards,

    Jan

  66. Aashish says:

    hi
    in my case the operation is getProductDetails, which takes parameter of type
    productinfo as shown below!

    how do handle this?

  67. nitgreen says:

    This is nice example with considerabl information, I was learning SOAP from W3Schools but this is more practical.

  68. Vas says:

    Hi Patrick,

    Fist of all great example/tutorial.
    I run your example without any issue on my website, however, once I changed to my own example i got an error.
    I have been struggling for few days but I have no luck .
    Hope you could help me figure it out.
    Here is part of the code which im using:

    password is a string
    username is an integer.

    $client = new SoapClient(“http://myURL.wsdl?WSDL”);
    $result = $client->CityList(array(‘username’=>123456,’password’=>’0123456′));
    At the above line I get the folling error:

    Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException:
    Server was unable to process request. —>
    System.NullReferenceException: Object reference not set to an instance of an object.
    at BIWS.BIWebService.LoginUser(SqlConnection myConn) at BIWS.BIWebService.CityList()
    — End of inner exception stack trace
    — in C:\Inetpub\vhosts\mywebsite.com\httpdocs\webservice\ws.php:68
    Stack trace: #0 [internal function]: SoapClient->__call(‘CityList’, Array)
    #1 C:\Inetpub\vhosts\mywebsite.com\httpdocs\webservice\ws.php(68): S
    oapClient->CityList(Array) #2 {main} thrown in
    C:\Inetpub\vhosts\mywebsite.com\httpdocs\webservice\ws.php on line 68

    Here is a list of function which I get from the server:
    array(16) {
    [0]=>
    string(53) “ShowBasicsResponse ShowBasics(ShowBasics $parameters)”
    [1]=>
    string(56) “ShowDetailsResponse ShowDetails(ShowDetails $parameters)”
    [2]=>
    string(59) “PerformancesResponse Performances(Performances $parameters)”
    [3]=>
    string(122) “PerformancesPOHPricesAvailabilityResponse PerformancesPOHPricesAvailability(PerformancesPOHPricesAvailability $parameters)”
    [4]=>
    string(59) “PremiumSeatsResponse PremiumSeats(PremiumSeats $parameters)”
    [5]=>
    string(47) “CityListResponse CityList(CityList $parameters)”
    [6]=>
    string(47) “NewOrderResponse NewOrder(NewOrder $parameters)”
    [7]=>
    string(50) “HeartbeatResponse Heartbeat(Heartbeat $parameters)”
    [8]=>
    string(53) “ShowBasicsResponse ShowBasics(ShowBasics $parameters)”
    [9]=>
    string(56) “ShowDetailsResponse ShowDetails(ShowDetails $parameters)”
    [10]=>
    string(59) “PerformancesResponse Performances(Performances $parameters)”
    [11]=>
    string(122) “PerformancesPOHPricesAvailabilityResponse PerformancesPOHPricesAvailability(PerformancesPOHPricesAvailability $parameters)”
    [12]=>
    string(59) “PremiumSeatsResponse PremiumSeats(PremiumSeats $parameters)”
    [13]=>
    string(47) “CityListResponse CityList(CityList $parameters)”
    [14]=>
    string(47) “NewOrderResponse NewOrder(NewOrder $parameters)”
    [15]=>
    string(50) “HeartbeatResponse Heartbeat(Heartbeat $parameters)”
    }

    I can get CityList results from my local machine using SOAPUI but not from the website.

    Note: the vendor is restricting access by IP and username and password.

    Hope you could help with issue.

    Cheers,

    Vas

  69. [...] I have just Googled some tutorials: server and client. Cannot find any English tutorial for client and server. Just take care when googling, that the [...]

  70. Hi Vas,

    Could it be that there’s no database connection on the remote host? The message ‘System.NullReferenceException: Object reference not set to an instance of an object.at BIWS.BIWebService.LoginUser(SqlConnection myConn)’ seems to refer to that I think.
    As I cannot see the WSDL file you’re using: is it correct the method you’re calling expects a username and password as parameters?

    Cheers,

    Patrick

  71. Hi Aashish,

    I might be missing something, but I can’t find the details you’re referring to. However, as the parameter is of type productinfo, which is not a standard object/type, I think you should check the WSDL file to see how you should construct the productinfo parameter. Probably it’s a complex type (e.g. consists of various simple or complex types like string/int or objects).

    Cheers,

    Patrick

  72. Pete says:

    Hi Patrick,

    I was able to implement your example and retrieve data with no problem. I’m trying to get High Low Tide Pred data from this website http://opendap.co-ops.nos.noaa.gov/axis/ and can’t seem to modify the script properly to accept multiple parameters. Would it be possible for you to provide an example script and form to help me get started?

    Thx in advance.

  73. an phong says:

    hi admin!
    i have a problem relate for web service.
    this article very good about client in web service, but i have a problem about server in web service.
    admin has example about i need, please send me pass address email!
    thanks you so much!

  74. Vas says:

    Hey Patrick,

    Thanks for the reply.

    I don’t think is the DB connection issue, because the company which provides the webservice is saying that I’m hiting their server, but they don’t give more info then that.

    I tried to make a call with our username and password as parameters and get the same error.

    Here is the output of WSDL file:

    -
    -
    -
    -
    -
    -

    -
    -
    -
    +

    -
    -

    -
    -
    -

    -
    -
    -
    -
    -
    -

    -
    -
    -

    -
    -
    -
    -
    -
    -

    -
    -
    -

    -
    -
    -
    -
    -
    -

    -
    -
    -

    -
    -
    -
    -
    -
    -

    -

    -
    -
    -
    -
    -
    -

    -
    -
    -

    -
    -
    -
    -
    -
    -

    -

    -
    -
    -
    -
    -
    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -
    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -

    -
    -

    -

    Thanks a lot for your help.

    Cheers,
    Vas

  75. Hello Patrick,
    Thanks for the great article. It surely works great but my requirement is little different. I am supposed to pull data from a seperate WSDL and it gives me error as below …

    Fatal error: Uncaught SoapFault exception: [Client] DTD are not supported by SOAP in F:\wamp\www\soap\client.php:5 Stack trace: #0 [internal function]: SoapClient->__call(‘getUpdate’, Array) #1 F:\wamp\www\soap\client.php(5): SoapClient->getUpdate(‘doggy’) #2 {main} thrown in F:\wamp\www\soap\client.php on line 5

    Tired of it … can you help on this?

  76. Hi Vas,

    So that company will only tell you that the request reaches their server. Hmm.. but they won’t tell you if you use the right credentials?
    Well.. the error message is a cryptic one, not really describing the actual error. I’m still not able to see the result you wanted to post. Is it possible to put it somewhere on a service like pastie.org or pastebin and provide the link?

    Cheers,

    Patrick

  77. Hi O. Nepal,,

    From what I read on various blogs it mostly has something to do with the server not responding with a proper SOAP message, but rather an HTML page (like a 403 or 404 error message or just a web page). Is the receiving end (the server sided part) handling the request properly and serving responses in SOAP format? (Did you code the server part?)

    Cheers,

    Patrick

  78. Vas says:

    Hey Partric,

    Thanks a lot for getting back to me.
    Here is the link of the webservice http://qawebservices.broadwayinbound.com/BIWebService.asmx?wsdl

    but they restrict it by IP so I’m not sure that your will get anything.
    However, as you requested it fro Pastie.org here is the link.
    http://pastie.org/2870571
    Hope you will be able to see the XML .
    Your help is greatly appreciated.

    Cheers,

    Vas

  79. Sitansu says:

    Nice example.Keep it up.

  80. Jan Møller says:

    Hello Patrick van Kouteren.

    This is the most useful, short and informative description i have found on the subject PHP, WSDL and SOAP!

    Thanx a lot.

    Jan Møller, Denmark

  81. Jitendra says:

    very nice example for who don’t aware about soap

  82. Dave Joyce says:

    Great example and easy to follow. Just a follow up to your action=’index.php’ comment. I had a customer server (NT) crash and had to re-install a custom php database program on W7 computer with latest XAMPP code and found that the action=$_SERVER['PHP_SELF'] also cause problems.

    I changed all form actions that call themselves to just action=”. Then html forces the correct action. Worked fine with your example too. Not sure if this works on all servers.

    Thanks again for the timeless tutorial.

    Dave Joyce, Canada

  83. soap newb says:

    This is such a great article, simple yet get the point across of what SOAP does, and how to use it with php. nice!

  84. Hannu-Pekka Heinäjärvi says:

    Thanks, really good article!

  85. Roshni says:

    Thanks for the good article

  86. Milap says:

    Hello Patrick,

    I just wanna say you , thanks a lot for this tutorial.
    I was really helpful for me when i started to learn SOAP ..

    I have 1 question,
    how can we create WSDL like http://footballpool.dataaccess.eu/data/info.wso?wsdl ?

    Great Work ..
    God bless you..

  87. thank you for your easiest example ever

  88. Hi Milap,

    You COULD of course create it by hand (hehe), but often there are tools which can create a WSDL file for you. As far as I know there wasn’t a native PHP thingy for it (yet). However, there must be some smart guy who’s done this already.

    (It basically comes down to indexing the methods and putting the docs / metadata you’ve defined in the SOAP API into a specific (read: WSDL) format)

    Cheers,

    Patrick

  89. Dimitris says:

    Hi Patrick,

    I just came across to your php example and i tried to get some knowledge of it but it seems that i’m having problems with arrays within arrays.

    My question is : How do i form my arrays in order to get the result correctly?

    usefull information:

    using soapui tests i get as request from service:

    ?
    ?
    ?
    ?

    and as result:

    UNF

    at the moment i’ve done this in php :

    $HeaderInfo= array(‘AgentCode’ => $AgentCode,’AgentUser’ => $AgentUser,’AgentPasswd’ => $AgentPasswd,’AgentSignature’ => $AgentSignature);

    $PricingPerPassenger = array(‘ClassAbbr’=>’A1′,’PassType’=>’AD’);
    $PricingPerVehicle = array(‘VehicleType’=>’IX1′,’Meters’=>’425′);

    $PricingReq[]=array();
    $PricingReq[]= new SoapVar($Data_,SOAP_ENC_OBJECT);
    $PricingReq[]= new SoapVar($PricingPerPassenger,SOAP_ENC_OBJECT,null,null,’PricingPerPassenger’);
    $PricingReq[]= new SoapVar($PricingPerVehicle,SOAP_ENC_OBJECT,null,null,’PricingPerVehicle’);

    $HeaderInfo = new SoapVar($HeaderInfo SOAP_ENC_OBJECT);
    $PricingReq= new SoapVar($PricingReq, SOAP_ENC_OBJECT);

    $client = new SoapClient(“http://something-wsdl”,array(‘trace’=>1,’exception’=>0));

    $client->function($HeaderInfo,$PricingReq);

    but i’m getting back from the service a response with no values

    myrequest with above php code:

    xxxxxxxxxxxxxxxxxxx201211010800TSTTTTT00002A1ADPV3

    service response:

    any help will be much appeciated

    thanks

    Dimitris

  90. Dimitris says:

    i removed some < in order to post results, sorry for this :)

    using soapui tests i get as request from service:

    ?
    ?
    ?
    ?

    and as result:

    UNF

    myrequest with above php code:

    xxxxxxxxxxxxxxxxxxx201211010800TSTTTTT00002A1ADPV3
    –>

    service response:

  91. david says:

    url does not open

  92. Max Qubit says:

    Great article for beginners with PHP SOAP. Just what I needed. Thx!

    Brgds,
    Max Qubit

  93. Yusuf says:

    hi great article…could you send me an email as i will need your help for a project.thanks

  94. Hi Yusuf,

    You can reach me trough here, or Twitter, if it’s short :)

    Cheers,

    Patrick

  95. Aspirin says:

    Hi!
    Your example worked like a charm, BUT when using that with this link
    https://secure.incab.se/axis2/services/DTServerModuleService_v1?wsdl
    i got a “Extra content at the end of the document” Fatal Error.
    any suggestions or ideas how to connect?

  96. vinod palan says:

    Hi,
    Code looks great but I am getting this error can you please help.

    Warning: SoapClient::__construct(https://…../departments/ps/DPM/_vti_bin/Lists.asmx?WSDL) [function.SoapClient---construct]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in …/testsoap.php on line 33

  97. Hi Vinod,

    Is the WSDL file you’re trying to access at a secured area? Seems like it expects HTTP authentication. If you try to access the WSDL file through your browser, do you get a login prompt?

    Cheers,

    Patrick

  98. Hi Aspirin,

    Hmmm.. that’s a nice one. Did you perform a search on the internet on that? And do you know at which line it goes wrong? This StackOverflow question is about the same problem. I don’t know if it’s a PHP bug or not.

    Cheers,

    Patrick

  99. I have started to develop an API for one of my project which will be providing direct access payment services. It will be like a online payment system. For communications between merchant and my API i have selected to use SOAP and to be honest, it is my first time to work with SOAP :) . This article provided me a basic start and intro to SOAP and now i am running the sample code and arranging it for my use.
    Thank you for a good post.

  100. tuba says:

    Thank you for the tutorial , let me try. I need to create somethng where user can check user/pass and return correct xml.

  101. kittypunkz says:

    Thanks for your sharing! it’s great tutorial and i can do it! :)

  102. Daily1Game says:

    This is very simple and easily understandable example, great post.

  103. Sree says:

    Hi Patrick,

    Great example for the starters. But I am having issues. I just tried implementing your code. Please tell me what I should check.

    Notice: Undefined property: stdClass::$tTopGoalScorer

  104. kchang808 says:

    Hi Patrick,

    As everyone is saying, thank you for a great example and getting me started on SOAP calls. I tired to get your updated soaptest.php file to work but I am stuck. In the soaptest.php file I changed the URL to

    $client = new SoapClient(“http://footballpool.dataaccess.eu/data/info.wso?wsdl”);

    as the URL in the file was

    $client = new SoapClient(“http://euro2008.dataaccess.eu/footballpoolwebservice.wso?WSDL”);

    which did not work. So, I can get the WSDL but when the PHP SoapClient makes the request

    $result = $client->TopGoalScorers(array(‘iTopN’=>$topn));

    I get this error

    Notice: Undefined property: stdClass::$tTopGoalScorer in D:\Apache\htdocs\SimplePHPSOAPExample\soaptest.php on line 21

    which leads to this error

    Warning: Invalid argument supplied for foreach() in D:\Apache\htdocs\SimplePHPSOAPExample\soaptest.php on line 32

    This leads me to believe that the call failed and no result object was returned. I looked at the WSDL and it is as you have your example (meaning that the operation name is still TopGoalScorers) so I’m at a loss as we why the call is failing. I did put and error_log() stmt in the code to check on the value of $topn and $_POST['topn'] and they look fine

    [Thu May 24 13:52:39 2012] [error] [client 127.0.0.1] KEN $topn => 3 $_POST[topn] => 3, referer: http://localhost/SimplePHPSOAPExample/soaptest.php

    The PHP error log reflects what I see in the browser

    [Thu May 24 13:52:42 2012] [error] [client 127.0.0.1] PHP Notice: Undefined property: stdClass::$tTopGoalScorer in D:\\Apache\\htdocs\\SimplePHPSOAPExample\\soaptest.php on line 21, referer: http://localhost/SimplePHPSOAPExample/soaptest.php
    [Thu May 24 13:52:42 2012] [error] [client 127.0.0.1] PHP Warning: Invalid argument supplied for foreach() in D:\\Apache\\htdocs\\SimplePHPSOAPExample\\soaptest.php on line 32, referer: http://localhost/SimplePHPSOAPExample/soaptest.php

    Hope you can help.

    Regards…Ken

  105. frozeng says:

    Notice: Undefined property: stdClass::$tTopGoalScorer

    This seems to be caused by the the server returning no data currently for TopGoalScorer (possibly this is outside of a season or maybe its broken).

    http://footballpool.dataaccess.eu/data/info.wso gives a list of the methods and a form to test them. TopGoalScorer currently returns an empty array.

    The following method works:
    $result = $client->TopSelectedGoalScorers(array(‘iTopN’ => 1));
    $array = $result->TopSelectedGoalScorersResult->tTopSelectedGoalScorer->sName;
    var_dump( $array );

  106. kchang808 says:

    Thanks forzeng, that makes sense. I tried your snippet, vardump($array) returns 1 name interestingly when I replace ‘iTopN’ => 1 with ‘iTopN’ => 10 and run it again, vardump($array) returns NULL. Do you think that’s just a bug with the web service?

    vardump() was a good debugging tool as well :-)

  107. Thanks that was easy. Advanced Documentation you find on php.net:
    http://php.net/manual/de/class.soapclient.php

  108. Rasmus says:

    Hey Patrick!

    Great guide, but I’m having trouble getting the results back from your example; I just get a blank page. I’m running PHP through MAMP (1.9) and SOAP _should_ be activated afaik. Any ideas on what might be the problem?

  109. Hello Rasmus,

    Is it about the actual retrieving of the results or do you already get a blank page when trying to access the form?
    Do you get any errors regarding SoapClient in your error_log?
    Can you read the WSDL file from the URL? (Does it give output in your browser?)
    If so, you can use some var_dump statements (as shown in earlier comments) to debug which step is not working.

    Cheers,

    Patrick

  110. David says:

    Great job! I do have a question, could you explain how to connect using an API with password and username as well as getting a information out?

  111. Chester says:

    Hi Patrick!

    Great job. I have only one doubt, it would be perfect if you could help me…
    I have a webservice that require a parameter to be sent as xml.
    Do you know how to send it, using php?

    Thanks in advance,
    Chester

  112. Bill Zimmerly says:

    Great article Patrick! You helped me with this. By the way, here’s another PHP goodie that I found VERY useful in my own SOAP experiments –> the var_dump() function! With it, it is easy to determine what the contents of ANY object being returned from the server is. It decomposes the objects very cleanly, and you can use it step-by-step to decode the arrays returned.

  113. Nadeem says:

    Great! Its help me a lot, to understand.

  114. Mohamed says:

    Good job thank u

  115. supachoup says:

    Thank you so much for your job, you litterally saved my life !!!!!!

  116. toorup says:

    I am a novice to web services and coming across is a blessing. I would be grateful if you can send me the source code. Thanks in advance

  117. Hi toorup,

    All code in the blogpost is basically all there is!

    Cheers,

    Patrick

  118. toorup says:

    Never mind sending me the source code… I copied the code I could lay my hands on here and I was actually able to change the table format to print out in xml format… Here is the edited code below… Nice tutorials… Thanks man!

    TopGoalScorers(array(‘iTopN’=>5));

    if ($_POST['topn'] > 0 && (int) $_POST['topn'] TopGoalScorers(array(‘iTopN’ => $topn));
    // Note that $array contains the result of the traversed object structure
    $array = $result->TopGoalScorersResult->tTopGoalScorer;
    header(“Content-type: text/xml”);
    print ”

    “;
    foreach($array as $k=>$v){
    print ”

    ” . ($k+1) . ”
    ” . $v->sName . ”
    ” . $v->iGoals . ”
    “;
    }
    print “”;
    }
    else {

    ?>

    <form id="topscorers" action="” method=”post”>
    How long should your topscorers list be? (Choose a digit between 1 and 20).

  119. Good blog about client in web service, and it is very simple and easily understandable example, great post.

  120. behnam says:

    Hey man, I was wondering if you could help me:

    This is my wsdl
    https://smtpi.siteminder.com/siteconnect/services/siteconnect.wsdl

    They request data from me with this format:
    http://hotels2go.com.au/sm/receive.xml

    They expect my response to be this format:
    http://hotels2go.com.au/sm/OTA_HotelAvailRS.php

    I thought I use something like this but your code looks like the right way to go:
    $xml = simplexml_load_file(“receive.xml”);
    $xml->registerXPathNamespace(‘ot’, ‘http://www.opentravel.org/OTA/2003/05′);
    $hotel_ref = $xml->xpath(“//ot:HotelRef”);
    $attributes = $hotel_ref[0]->attributes();
    $hotel_id = $attributes['HotelCode'];

    Can you please help me with this or show me how you do it?

    Thanks

  121. Guillermo says:

    De gran ayuda tu artículo.

    Thank for article. I was helpful.

    Guillermo

  122. laeeq says:

    really usefull post…Thanks

  123. Rocky says:

    Can you please send me example of the code.

  124. Iulian says:

    Good post, well explained.

  125. Hi Patrick,
    I have created a web services for one of my project using php soap. Currently i process all the returned data in arrays (associative arrays).
    I want to know is it possible to get the returned data in clean xml format without the soap headers?
    I also have a solution (not tested yet), that i can take the results at server side, and create an xml string, and that xml string is returned back to the client, so the client will have the result in an array and the value will be an xml structure. But not sure about this.
    Can you please give me a guide line here.
    May thanks for the good post and your help.

  126. Mahu says:

    This post is really old but it helped me in a way any other soap tutorial could do. Thanks a lot!

  127. Jashid says:

    Patrick,

    After running this code i got an error.

    Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://footballpool.dataaccess.eu/data/info.wso?wsdl’ : failed to load external entity “http://footballpool.dataaccess.eu/data/info.wso?wsdl” in /var/www/html/testphp/form_submission.php:5 Stack trace: #0 /var/www/html/testphp/form_submission.php(5): SoapClient->SoapClient(‘http://football…’) #1 {main} thrown in /var/www/html/testphp/form_submission.php on line 5

  128. Mohamed says:

    Hello how can I sort by Goal on display please help me.

  129. click here says:

    I cannot get this to work .. i’m hoping you can help once i hit the client call i get nothing after that i.e. (stops my script, blank page) …

  130. Dhaval says:

    Hi,

    Thanks for a great explanation with example.

    I’m beginner in using SOAP. I need to ask you one question, the WSDL file I’m using needs to pass header with user/pass but I don’t know how to do that as I’m a beginner. Can you tell me how to pass whole header through SoapClient example you provide.

    Thanks,
    Dhaval

  131. blackwolf says:

    Thanks for the great tut. it works and i did a change to get all the player names and country for testing.

    im currently working on a bit of code that has to use WSDL, “kenteken” submit and retrieve car information however i cant get the darn thing to work.

    if you have some time can you take a piek @ my code? and tell me what im doing wrong.

    thanks,

  132. Mikaelcom says:

    For those who wants to use SOAP Web Services in PHP easily, I would recomand you to use this package https://github.com/mikaelcom/WsdlToPhp which can be very usefull. Test it and tell me what you think about it ;)

    Regards

  133. pututik says:

    this help me to understand the basic of soap, thanks patrick

  134. Cenital says:

    First of all thank you for sharing your work Patrick.
    I have a short question hope you can help me because I´m a little bit lost on that.

    I nedd to get some data from SOAP server but it´s not offering no WSDL… but I have the data sctructure for the data that SOAP server is waiting for, I have the IP and the port address too where I should send the request.

    So questión is…. How can I do a SOAP request without having a WSDL?. Is it possible using PHP-SOAP?.

    Thank you so much in advance.
    Best regards.

  135. Cenital says:

    …one more thing related to the prior question. I have a raw data to send into the call method but I have no name for the parameter. What I mean is that I have no pair ‘param name’, ‘param value’ , what I have it´s just ‘param value’ .. This is because the SOAP server it´s just an integration engine wich receives the values and it´s acting like a gateway to other aplication so that It´s because I guess no ‘param name’ is needed.

    Thank´s (once again) :)

  136. monish says:

    First f all thnkx 4 the wndrful tut..

    But when i tried i am getting

    Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://euro2008.dataaccess.eu/footballpoolwebservice.wso?WSDL’ : failed to load external entity “http://euro2008.dataaccess.eu/footballpoolwebservice.wso?WSDL” in /home/monish.george/project/soaptest.php:14 Stack trace: #0 /home/monish.george/project/soaptest.php(14): SoapClient->SoapClient(‘http://euro2008…’) #1 {main} thrown in /home/monish.george/project/soaptest.php on line 14

    how to i fix this issue?

    and when i tried ur WSDL link it gives me

    The connection to the server was reset while the page was loading.

    so is ur link to the WSDL is still active ?

    any way thnx again for ur tut…

  137. vish says:

    Hello,
    I passed this url to soapclient
    https://webservices-staging.toptable.com/Venue1.1/VenueService.svc?WSDL
    but i get soap parsing error,what could be the reason can you please help me?

    $client =
    new SoapClient(“https://webservices-staging.toptable.com/Venue1.1/VenueService.svc?WSDL”);

    print_r($client);

    i get error here.

  138. Devendra says:

    This gave me basic idea about the SOAP..Nice article thanks

  139. Daniel says:

    The best example online, thank you friend, you saved me
    from buenos aires

  140. Hardik says:

    It is very nice great work

  141. Hardik says:

    It is very nice that you give such nice article to public. It help me a lot

  142. WarGot says:

    Good article.Thanks

  143. charles says:

    soo cool this tutorial is……A single skimming through and I was able to solve a problem that has otherwise disturbed me for a whole week.Thankssss!!!!!!!

  144. Dimitris says:

    Hello LOvely friend
    Everything here is looking fine, but is not working for me!!
    Here is my code

    0 && (int) $_POST['topn'] getForms(array(‘nomos’=>’Λάρισας’));
    // Note that $array contains the result of the traversed object structure
    $array = $result->getFormsReturn->item;

    print ”

    omada
    X
    Y

    “;

    foreach($array as $k=>$v){
    print ”

    ” . ($k+1) . ”
    ” . $v->omada . ”
    ” . $v->omada_desc . ”
    “;
    }

    print “”;
    }
    else {

    ?>

    Πόσες άδειες θέλεις? (>Επέλεξε από 1 εως 20).

    I have test the webservice with firefox soa client plugin and is working with the some elements!
    Can you help please and I will den an ouzo from Greece to you!

  145. Dimitris says:

    0 && (int) $_POST['topn'] getForms(array(‘nomos’=>’Λάρισας’));
    // Note that $array contains the result of the traversed object structure
    $array = $result->getFormsReturn->item;

    print ”

    omada
    X
    Y

    “;

    foreach($array as $k=>$v){
    print ”

    ” . ($k+1) . ”
    ” . $v->omada . ”
    ” . $v->omada_desc . ”
    “;
    }

    print “”;
    }
    else {

    ?>

    Πόσες άδειες θέλεις? (>Επέλεξε από 1 εως 20).

    Sorry!! here is the correct code!

  146. Dimitris says:

    if ($_POST['topn'] > 0 && (int) $_POST['topn'] getForms(array(‘nomos’=>’Λάρισας’));
    // Note that $array contains the result of the traversed object structure
    $array = $result->getFormsReturn->item;

    print ”

    omada
    X
    Y

    “;

    foreach($array as $k=>$v){
    print ”

    ” . ($k+1) . ”
    ” . $v->omada . ”
    ” . $v->omada_desc . ”
    “;
    }

    print “”;
    }
    else {

    ?>

    Πόσες άδειες θέλεις? (>Επέλεξε από 1 εως 20).

    <?php

    }

    O.K. now I understand how to paste here php code

  147. Dimitris says:

    I cannot understand how to paste my code…

  148. Dimitris, you can also paste your code at http://pastebin.com and link to it :)

  149. aksh says:

    hi patrick

    i cant connect to your remote wsdl file.i run your code in local wamp server but getting error like: Fatal error: SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://euro2008.dataaccess.eu/footballpoolwebservice.wso?WSDL’ : failed to load external entity “http://euro2008.dataaccess.eu/footballpoolwebservice.wso?WSDL”

  150. Cobus says:

    Hi Patrick

    I have created a php soap client and server. They work perfectly well in non-wsdl mode. But when I use the wsdl file for my service the soap server ignores the header with the client’s authentication details. Thus making the client’s authentication fail. Any help would be appreciated.

  151. WB says:

    If you are looking for a good start to a PHP SOAP Client generated directly from the WSDL file, take a look at http://www.apigenerator.com

    Includes some documentation with the generated classes.

    Hope it helps all of you somehow.

  152. Kuldeep Singh says:

    Nice short soap examples. Thankyou very much

  153. SD says:

    Hi Patrick,

    thanks for your nice article.
    im new in webservice.im using apache2triad and enabled extention of php_soap.dll,php_xml.dll,soap.wsdl_cache_enabled=0,

    but i can not make it working.would u please suggest anything in this regard?

    regards,
    SD

  154. Hi SD,

    Is there ANY form of output (either in the browser or the error_log) that can be of any help?

    Cheers,

    Patrick

  155. SD says:

    Hi patrick,

    im new in webservice.im using apache2triad and enabled extention of php_soap.dll,php_xml.dll,soap.wsdl_cache_enabled=0,

    Please help.

    here is my wsdl :

    Here is my soap-server.php :

    addfunction(“getCatalogEntry”);
    $server->handle();
    ?>

    Here is my soap-client.php :

    simple SOAP test

    getCatalogEntry($catalogId);

    } catch (SoapFault $fault) {

    echo “Error :”.$fault->getMessage();

    }

    echo $response;
    var_dump(var_dump);
    ?>

  156. SD says:

    Dear Parick,

    thanks for your reply.
    I Did not found any error log in error logfile and even in the browsing showing nothing i.e. blank.

    i want to give u my files (wsdl,server.php & client.php) to check and help.

    where can i paste these ?

    Thanks once again for your kindly reply.

  157. SD says:

    Dear Patrick,
    please find out my files :
    http://pastebin.com/fVbvw6hj

    appreciate your suggestion in this regard.

    regards,
    SD

  158. Joseph Kurt Leonardo says:

    Hi,

    I would just like to know how it process the information after you called “->TopGoalScorers()” and what file it called to return the vlaues?

  159. Raja says:

    Patrick i am using calling WCF service with .svc extension for payment, it uses https address.when i tried to request the service i got following error “SoapFault Object
    (
    [message:protected] => Failed to find the specified routing message element within the incoming message.
    [string:Exception:private] =>
    [code:protected] => 0
    [file:protected] => C:\wamp\www\multichoice\m_start.php
    [line:protected] => 16
    [trace:Exception:private] => Array
    (
    [0] => Array
    (
    [file] => C:\wamp\www\multichoice\m_start.php
    [line] => 16
    [function] => __call
    [class] => SoapClient
    [type] => ->
    [args] => Array
    (
    [0] => SubmitPayment
    [1] => Array
    (
    [paymentVendorCode] => RTTP_Ghana_PostOffice
    [transactionNumber] => 121305555
    [dataSource] => Angola_QA
    [smartCardNumber] => 4263998620
    [amount] => 1
    [currency] => USD
    [paymentDescription] => Test Payment
    [methodofPayment] => MOBILE
    [productCollection] => PRMW4
    )

    )

    )

    )

    [previous:Exception:private] =>
    [faultstring] => Failed to find the specified routing message element within the incoming message.
    [faultcode] => s:Client
    [detail] => stdClass Object
    (
    [RoutingFailure] => stdClass Object
    (
    [Message] => Failed to find the specified routing message element within the incoming message.
    )

    )

    )"
    please help to get this issue resolved, i have been trying for 2 days.

  160. Raja says:

    Data given is dummy data

  161. Louis says:

    This was a great jump start for a project I was working on.
    Thank you!

  162. Love this post , very helpful to work around SOAP request and Response with Error Tracking.

    Thanks

  163. alex says:

    Awesome guide. Really nice :) Helped me quite a lot

  164. Sonu Sindhu says:

    Thanks for the post.I am new and very easy to install for me.
    Thanks again
    sonu Sindhu

  165. gianluca says:

    thanks patrick

  166. Nazatul says:

    Hi Patrick,
    Help me..i’m stuck with this credential security in header..
    My xml is like this:

    qwerty
    123456

    already tried all the example found online, but failed. Really appreciate if u could help me.
    Thanks in advance :)

  167. Nazatul says:

    Hi Patrick,
    Help me..i’m stuck with this credential security in header..
    My xml is like this:

    <soapenv:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&quot; soapenv:mustUnderstand="1">
    <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd&quot; wsu:Id="UsernameToken-123">
    <wsse:Username>qwerty</wsse:Username>
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">123456</wsse:Password&gt;
    </wsse:UsernameToken>
    </wsse:Security>
    </soapenv:Header>

    already tried all the example found online, but failed. Really appreciate if u could help me.
    Thanks in advance :)

Leave a Reply

Your email address will not be published. Required fields are marked *


5 + = six