Solved

Help with SOAP Request

Posted on 2010-11-24
7
406 Views
Last Modified: 2012-05-10
I'm new to SOAP and really don't understand how to use it.  Can I get an example how to call for a request with the below code. They offer the WSDL but that confuses me even more.

http://bsn.wrx-us.com/MCmdWebservice/MCWebService.asmx?WSDL
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>
    <SendRTSCmdToModemResponse xmlns="https://bsn.wrx-us.com/MCmdWebService/">
      <SendRTSCmdToModemResult>string</SendRTSCmdToModemResult>
    </SendRTSCmdToModemResponse>
  </soap:Body>
</soap:Envelope>

Open in new window

POST /MCmdWebservice/MCWebService.asmx HTTP/1.1

Host: bsn.wrx-us.com

Content-Type: text/xml; charset=utf-8

Content-Length: length

SOAPAction: "https://bsn.wrx-us.com/MCmdWebService/SendRTSCmdToModem"



<?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:Header>

    <Authentication xmlns="https://bsn.wrx-us.com/MCmdWebService/">

      <Username>string</Username>

      <Password>string</Password>

    </Authentication>

  </soap:Header>

  <soap:Body>

    <SendRTSCmdToModem xmlns="https://bsn.wrx-us.com/MCmdWebService/">

      <_sModemId>string</_sModemId>

      <_sCmd>string</_sCmd>

      <_iResp>int</_iResp>

    </SendRTSCmdToModem>

  </soap:Body>

</soap:Envelope>

Open in new window

0
Comment
Question by:thaburner
  • 4
  • 3
7 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 34206464
Just a thought - avoid SOAP whenever you can and choose a RESTful interface instead.  You can read the wikipedia article on REST here:
http://en.wikipedia.org/wiki/Representational_State_Transfer

A good example of a RESTful web service is the Yahoo Geocoder or Placefinder:
http://developer.yahoo.com/geo/placefinder/

When you see how easy REST is compared to SOAP, you will wonder why anyone would ever use SOAP!
0
 

Author Comment

by:thaburner
ID: 34207677
My vendor is telling me I have to use SOAP that their server can not handle REST. I have found this site www.ApiGenerator.com and generated a class and think I got it working to an extent but I get an error.

Error Returned: (SendRTSCmdToModem) SOAP Error: - SOAP-ERROR: Encoding: object hasn't '_iResp' property
<?php

/**
 * 
 * Generated Proxy Class : MyGoogleClass (to interact with SOAP server at http://bsn.wrx-us.com/MCmdWebservice/MCWebService.asmx?WSDL)
 * @package MyGoogle
 * @version 1.00
 * @author www.ApiGenerator.com - Copyright (c) 2010. All rights reserved.
 * 
 * We take no responsibility for the accuracy of this generated code. Use or edit at your own risk.
 * 
 */
	
class MySOAP {
var $client = null;
var $soapUrl = 'http://bsn.wrx-us.com/MCmdWebservice/MCWebService.asmx?WSDL';
var $options = array(); 

/**
 * 
 * Class: MyGoogle - Construct Method
 * 
 */

function __construct()
{
$this->client = new SoapClient($this->soapUrl, $this->options);
//Insert Additional Constructor Code
}

/**
 * 
 * Class: MyGoogle - Destruct Method
 * 
 */

function __destruct()
{
unset ($this->client);
//Insert Destructor Code
}



//This is the one i need
function SendRTSCmdToModem($parameters ){
	try {
		$funcRet = $this->client->SendRTSCmdToModem($parameters );
	} catch ( Exception $e ) {
		echo '(SendRTSCmdToModem) SOAP Error: - ' . $e->getMessage ();
	}
	return $funcRet; 
}

		
}

?>

Open in new window

include("MySOAP.class.php");
$Request = new MySOAP();

$Data['Authentication'] = array('Username' => 'usr','Password' => 'pwd');
$Data['SendRTSCmdToModem'] = array('_sModemId' => '123456','_sCmd' => 'battery','_iResp' => '0');
	
echo $Request->SendRTSCmdToModem($Data);

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 34207731
Regarding this, "My vendor is telling me I have to use SOAP that their server can not handle REST."  That's ridiculous.  Your vendor does not know what she is talking about.  The WWW is a RESTful interface, so if they have a web site, they are already using REST!

The advantage of a RESTful interface is that every request is atomic and complete.  You put in a URL and you get back a web page.  It really is that simple.

Anyway, you might try removing '_iResp' => '0' from the second array.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:thaburner
ID: 34208144
The vendor is now closed for holidays, I will talk to someone else to see if they know what they are talking about. In the mean time I removed it from the Array and it still gives me the same error.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 34208900
Bummer.  Yeah, that is the kind of thing that you get with SOAP.  You wind up having to debug systems that run on another computer -- and you don't have any access to the other computer.
0
 

Author Comment

by:thaburner
ID: 34208985
Well far as I'm concerned SOAP is crap. Thanks for your help.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 34209055
Thanks for the points.  I agree with your assessment: crap.  In contrast to SOAP, here is an example of a RESTful web service.  If you put your URL behind HTTPS, your API keys will be hidden from view, and it will still be easy to use!
<?php // RAY_REST_get_last_name.php

error_reporting(E_ALL);







// DEMONSTRATE HOW A RESTFUL WEB SERVICE WORKS

// INPUT FIRST NAME, OUTPUT LAST NAME

// CALLING EXAMPLE:

// file_get_contents('http://laprbass.com/RAY_REST_get_last_name.php?key=ABC&resp=XML&name=Ray');







// OUR DATA MODEL CONTAINS ALL THE ANSWERS - THIS COULD BE A DATA BASE - AS SIMPLE OR COMPLEX AS NEEDED

$dataModel

= array

( 'Brian'   => 'Portlock'

, 'Ray'     => 'Paseur'

, 'Richard' => 'Quadling'

, 'Dave'    => 'Baldwin'

)

;





// SHOULD RESPONSE BE PLAIN TEXT OR XML FORMAT

$alpha = '';

$omega = '';

if ( (isset($_GET["resp"])) && ($_GET["resp"] == 'XML') )

{

    $alpha = '<response>';

    $omega = '</response>';

}







// TEST THE API KEY

$key = FALSE;

if (isset($_GET["key"])) $key = $_GET["key"];

if ($key !== 'ABC') die($alpha . 'BOGUS API KEY' . $omega);







// LOOK UP THE LAST NAME

$name="?";

if (isset($_GET["name"])) $name = $_GET["name"];



// IF THE URL NAME IS FOUND IN THE DATA MODEL

if (array_key_exists($name, $dataModel))

{

    // RETURNS THE LAST NAME FROM THE DATA MODEL

    die($alpha . "$dataModel[$name]" . $omega);

}



// RETURNS THE UNKNOWN NAME INDICATOR

else die($alpha . 'UNKNOWN' . $omega);

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now