Help with SOAP Request

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

thaburnerAsked:
Who is Participating?
 
Ray PaseurConnect With a Mentor Commented:
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
 
thaburnerAuthor Commented:
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
 
Ray PaseurCommented:
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
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
thaburnerAuthor Commented:
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
 
Ray PaseurCommented:
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
 
thaburnerAuthor Commented:
Well far as I'm concerned SOAP is crap. Thanks for your help.
0
 
Ray PaseurCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.