NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
RPC with XML document as parameters


Joined: 10 Jun 2008
Posts: 1
Location: Spain
Reply with quote
Hello,

I need to program a WEB service that implements a single procedure. The only argument of this procedure is an XML document.
Basically, the client send something like:

------------------------------------------------------------------------
POST /mywebservice/interumoservice.asmx HTTP/1.1
SOAPAction: "Mycompany/Webservice/PutAlarm"
Content-Type: text/xml; charset="utf-8"
User-Agent: Borland SOAP 1.2
Host: 192.168.0.206
Content-Length: 951
Connection: Keep-Alive
Cache-Control: no-cache


<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<PutAlarm xmlns="Mycompany/Webservice">
<xmlMessage>
<?xml version="1.0" encoding="iso-8859-1"?>
<Command>
<Alarm>
<Sender>Mycompany</Sender>
<Device>
<DeviceID>1234567890</DeviceID>
</Device>
<Criterium>100</Criterium>
<Voice>false</Voice>
<Time>30/5/2008 9:41:39</Time>
<Position>
<Longitude>E4,7767</Longitude>
<Latitude>N51,8283</Latitude>
<Speed>0</Speed>
<Altitude>0</Altitude>
<Heading>180</Heading>
<TimeStamp>30/5/2008 9:41:39</TimeStamp>
</Position>
</Alarm>
</Command>
</xmlMessage>
</PutAlarm>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

------------------------------------------------------------------------


The server I wrote is :


------------------------------------------------------------------------

$server = new soap_server(); // Create a server
$server->debug_flag = true;

// Initialize WSDL support
$server->configureWSDL('MycompanyCommandInterface', 'urn:Mycompany/MycompanyCommandInterface');

// Register the PutAlarm method to expose
$server->register( 'PutAlarm', // method name
array('xmlMessage' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:Mycompany/MycompanyCommandInterface', // namespace
'urn:MycompanyCommandInterface#PutCommand', // soapaction
'rpc', // style
'encoded', // use
);

if(SW_ISDEBUGSET)
{
LogError(LOG_FILE, "server.php: LOG002. HTTP_RAW_POST_DATA = ");
LogError(LOG_FILE, $HTTP_RAW_POST_DATA);
}

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);


//
// PutAlarm()
//
// Parameters: $xmlMessage -> XML document that contains the request
//
// Returns: string
//

function PutAlarm($xmlMessage)
{
$answer = RES_OK; // Result to be sent back to client

if(SW_ISDEBUGSET)
{
LogError(LOG_FILE, "server.php:PutAlarm() LOG001. xmlMSG = ");
LogError(LOG_FILE, $xmlMessage);
}
try
{
$svr_request = new svrMsg($xmlMessage);
if($svr_request->isSupported())
{
$svr_request->process(); // Digest the XMLdoc
}
else
{
$answer = RES_NOTSUPPORTED;
}
}
catch(Exception $e)
{
$answer = RES_INTERROR;
}
return new soapval('return', 'string', $answer);
}

------------------------------------------------------------------------


I have tried with all combinations for "style" and "use" inside the register method for server. None of them seems to work.
I do not know what else to try. All examples I get show how to do RPC using "arrays" as params. None of the examples I have found shows how to pass and XML doc between client and server.

Help will be much appreciated.

BR / Juan
View user's profileFind all posts by juannogueraSend private message
RPC with XML document as parameters
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic