Skip to content

Commit

Permalink
Feature: Added support for "literal wrapped". (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
deivide committed Mar 9, 2023
1 parent 0a4d7a2 commit a5fd9cb
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/nusoap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7599,7 +7599,7 @@ function __construct($endpoint, $wsdl = false, $proxyhost = false, $proxyport =
* @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
* @param boolean $rpcParams optional (no longer used)
* @param string $style optional (rpc|document) the style to use when serializing parameters (WSDL can override)
* @param string $use optional (encoded|literal) the use when serializing parameters (WSDL can override)
* @param string $use optional (encoded|literal|literal wrapped) the use when serializing parameters (WSDL can override)
* @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors
* @access public
*/
Expand All @@ -7615,6 +7615,8 @@ function call($operation, $params = array(), $namespace = 'http://tempuri.org',
$this->faultcode = '';
$this->opData = array();

$usewrapped = false;

$this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
$this->appendDebug('params=' . $this->varDump($params));
$this->appendDebug('headers=' . $this->varDump($headers));
Expand Down Expand Up @@ -7688,6 +7690,16 @@ function call($operation, $params = array(), $namespace = 'http://tempuri.org',
$nsPrefix = 'ns' . rand(1000, 9999);
// serialize
$payload = '';

if ($use = 'literal wrapped') {
// 'literal wrapped' is only sensible (and defined) for 'document'.
if ($style == 'document') {
$usewrapped = true;
}
// For compatibility with the rest of the code:
$use = 'literal';
}

if (is_string($params)) {
$this->debug("serializing param string for operation $operation");
$payload = $params;
Expand All @@ -7708,6 +7720,22 @@ function call($operation, $params = array(), $namespace = 'http://tempuri.org',
$encodingStyle = '';
}
}

// wrap document/literal wrapped calls with operation element
if ($usewrapped) {
// (This code block was based on http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
// and tailored to the needs of one specific SOAP server, where no nsPrefix was seen...
$this->debug("wrapping document request with literal method element");

if ($namespace) {
$payload = "<$operation xmlns=\"$namespace\">" .
$payload .
"</$operation>";
} else {
$payload = "<$operation>" . $payload . "</$operation>";
}
}

// wrap RPC calls with method element
if ($style == 'rpc') {
if ($use == 'literal') {
Expand Down

0 comments on commit a5fd9cb

Please sign in to comment.