Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-19-2009, 02:15 PM   #1
LQ Newbie
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
Help forming a SOAP client call with PHP

Hello all. Admittedly I an quite new to the world of SOAP. I've got the basics covered and am able to communicate with the Soap Server that my client has provided. But I'm having some trouble forming data into the required arrays so that the request shows up in proper format at the server.

<PostAssessment xmlns="">
  <AssessmentOrderRequest xmlns:xsi="" xmlns:xsd="">
    <ClientId idOwner="DDI" xmlns="">
      <IdValue name="Company">9876</IdValue>
      <IdValue name="Location">54321</IdValue>
      <IdValue name="Client Key">A-Client-Key</IdValue>
    <ClientOrderId idOwner="DDI" xmlns="">
      <IdValue name="Client Order Number">Name-of-the-order</IdValue>
The following snippet shows what I have so far...
$ClientId['IdValue'] = array( 'name' => 'Company' );

$Request['ClientId'] = $ClientId;

'ProjectKey' => 'ABCDE',
'UserName' => 'JohnDoe',
'Password' => 'JDPassword',
'AssessmentOrderRequest' => $Request );

$result = $client->PostAssessment( $param );
When checking the __getLastRequest(), everything looks good up to that point. I just can't get the value "9876" assigned to <IdValue name="company">. Everything I've tried gets a response from the server like this:
<IdValue name="Company"/>
instead of this:
<IdValue name="Company">9876</IdValue>
If anyone can help point me in the right direction, I would greatly appreciate it.

Old 03-20-2009, 10:04 AM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

Just to make sure we're all on the same page,

1. You're probably using the SOAP extension with PHP 5, and you're probably creating your client object something like this:
<?php # GetTemp.php
# Copyright (c) 2005 by Dr. Herong Yang,
   $client = new SoapClient
2. If so, PHP will automagically read the .wsdl, and your client object can read the SOAP data with "get" methods like this:
echo("\nReturning value of getTemp() call: ".
3. Your client's "getTemp()" call will have generated a SOAP request to the server, and the SOAP response will look something like this:[quote]
<?xml version='1.0' encoding='UTF-8'?>
<ns1:getTempResponse xmlns:ns1="urn:xmethods-Temperature-Demo"
<return xsi:type="xsd:float">52.0</return>
The result you'll see in the browser will look something like this:
Returning value of getTemp() call: 52
4. Now:
Q: How do you set a SOAP value?
A: Easy. You make a method call from your client object to the server (just like above). Only you pass one or more parameters in your argument:
echo("\nReturning value of getTemp() call: ".
In other words:
1. The WSDL defines the "protocol" - describing the *methods* client and server will use to exchange data, and the data these methods will exchange

2. The PHP SOAP extension "wraps" the WSDL-specific protocol for you, permitting you to read (and, implicitly, write) data to and from the server with the appropriate method calls.

I hope that helps (at least a little bit).

Old 03-20-2009, 11:42 AM   #3
LQ Newbie
Registered: Feb 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Originally Posted by paulsm4 View Post
Hi -

Just to make sure we're all on the same page,

1. You're probably using the SOAP extension with PHP 5,
Yes, I am using the SOAP extension within PHP 5. I have got my script working to the point that it grabs the WSDL properly. My client has defined a complex XML of which I only posted a portion of it. Once I can get past this part, I can then apply my new knowledge to the rest of the XML. What I've done so far, goes beyond any of the examples you've referenced.

Thanks for the input.....
Old 03-20-2009, 12:41 PM   #4
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
In your original post, I wasn't clear if you were asking how to set a value (A: use the methods your WSDL provides), or if you simply weren't seeing the values you expected to see (A: what you see should be what's defined by the WSDL).

Either way: the answer starts with the WSDL (you can't access something with PHP that isn't there in the SOAP response; you can't force something into SOAP that isn't expected by the WSDL).

'Hope that helps .. PSM


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP SOAP server returns array using NuSOAP Library mohtasham1983 Programming 2 11-18-2007 09:27 PM
call a php file petenyce Linux - Newbie 3 11-23-2005 03:21 AM
advx php soap support? schallig Mandriva 1 07-15-2005 01:15 AM
Call a shell script from php? jharper101 Programming 2 02-15-2005 12:51 AM
call php scripts djgerbavore Programming 3 11-30-2004 07:17 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:24 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration