Solved

Help with SOAP Request

Posted on 2010-11-24
7
411 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 110

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 110

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 110

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 110

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Link Stopped Working 7 32
Conditional Array Element 7 28
How to convert PHP array into string ? 16 27
syntax error, unexpected end of file 4 17
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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 i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

751 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