Question:
How do you pass in values to a complex type from a client utilizing SOAP?
Summary:
The following WSDL SOAP Request "ReceiverMenuDeleteRequest" requires the element named "Authentication" and "TID".
With "TID"; I believe I can pass in a string value like:
array('TID'=>'06000C18',
However, how do I pass values to the complexType "Authentication"?
Currently, I have it set-up as:
$Authentication = array('RqstAppl'=>'CMDLINK', 'RqstApplVers'=>'1.00', 'Client'=>'KBREQ', 'User'=>'OPSSUPPORT', 'Pswd'=>'ENCRYPTED');
$result = $client->call('ReceiverMenuDeleteRequest', array('TID'=>'06000C18', 'Authentication'=>$Authentication));
The errors I keep receiving are:
Response Envelope: Error: HTTP Error: socket read of headers timed out
My Request SOAP envelope is not filled in:
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:si="http://soapinterop.org/xsd"
xmlns:ns6="http://soap.dtn.com">
<SOAP-ENV:Body>
<ns6:ReceiverMenuDeleteRequest xmlns:ns6="http://soap.dtn.com">
<ReceiverMenuDeleteRequest xsi:nil="true"/>
</ns6:ReceiverMenuDeleteRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Below is a snippet of the WSDL and the full PHP code that I use to call the WSDL.
Thank you for reading this post.
WSDL:
<xsd:complexType name="Authentication">
<xsd:sequence>
<!-- Request Application -->
<xsd:element maxOccurs="1" minOccurs="1" name="RqstAppl" type="xsd:string"/>
<!-- Request Application Version -->
<xsd:element maxOccurs="1" minOccurs="1" name="RqstApplVers" type="xsd:string"/>
<!-- Client using Request Application -->
<xsd:element maxOccurs="1" minOccurs="1" name="Client" type="xsd:string"/>
<!-- Client's User using Request Application -->
<xsd:element maxOccurs="1" minOccurs="1" name="User" type="xsd:string"/>
<!-- Client's User Password (Encrypted) -->
<xsd:element maxOccurs="1" minOccurs="1" name="Pswd" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ReceiverMenuDeleteRequest">
<xsd:sequence>
<xsd:element
maxOccurs="1"
minOccurs="1"
name="AuthInfo"
nillable="true"
type="color1:Authentication"/>
<xsd:element maxOccurs="1" minOccurs="1" name="TID" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
PHP:
<?
require_once('nusoap.php');
$wsdl = 'http://color-app-dev.eng.dtn.com/ColorSystemInterface.wsdl';
$client=new soapclient($wsdl, true);
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
// Call the SOAP method
$Authentication = array('RqstAppl'=>'CMDLINK', 'RqstApplVers'=>'1.00', 'Client'=>'KBREQ', 'User'=>'OPSSUPPORT', 'Pswd'=>'ENCRYPTED');
$result = $client->call('ReceiverMenuDeleteRequest', array('TID'=>'06000C18', 'Authentication'=>$Authentication));
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}
echo 'Web Service: Color System Interface ReceiverMenuDeleteRequest<br>';
echo 'WSDL: '.$wsdl.'<br>';
echo 'Parameters: ';
print_r($param);
echo '<br><br>Response Envelope: ';
if(!$err = $client->getError()){
print_r($response);
} else {
print 'Error: '.$err;
}
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>