|
| Required NuSoap feature/case missing!? | |
Joined: 18 Jun 2008 |
Posts: 7 |
Location: India |
|
|
Posted: Tue Jun 17, 2008 11:53 pm |
|
|
|
|
|
Hello,
We have used a local WSDL file with PHP SOAP to request a web-service and got
response successfully. As our head office team uses NuSOAP, we had to migrate
the code to NuSOAP and found that it's not working like it worked with PHP-SOAP.
As I have tried to go over the nusoap.php, I observed the following:
The original wsdl file has something like:
<wsdl:message name="getXXXRequest">
<wsdl:part element="tns1:getXXX" name="part"/>
</wsdl:message>
|
As the `name` for wsdl:part is given as " part", nusoap is
creating the message as:
<part>[ the message body ]</part> |
However the server is failing with "internal server error" when that message is posted.
When the message is sent like:
<tns1:getXXX>[ the message body ]</tns1:getXXX> |
then the server accepts it and sends the response.
This worked with PHP-SOAP as PHP-SOAP has created second type of message.
Now I do not know where lies the problem:
1) Either Sever is not accepting the message as it should be with <part>xxxxx</part>
2) Or NuSoap is missing a feature to consider the second case
3) Or PHP-SOAP is either considering both cases or sending the wrong case!?
Kind Regards,
Sanjeev
|
Last edited by sanjeev_any on Thu Jun 19, 2008 6:14 am; edited 1 time in total
|
|
| Tweaking nusoap.php | |
Joined: 18 Jun 2008 |
Posts: 7 |
Location: India |
|
|
Posted: Wed Jun 18, 2008 2:56 am |
|
|
|
|
|
For now, to carry on, I have made the following change to nusoap.php (version 0.7.2) in serializeType() line number: 5452
replaced: $xml = "<$name$elementNS>$value</$name>"; |
with: $xml = "<".$this->getPrefixFromNamespace($ns).":$uqType>$value</".$this->getPrefixFromNamespace($ns).":$uqType>"; |
I fear it might break some other calls that use nusoap.php!
Let me know what needs to be done!?
Kind Regards
Sanjeev
|
|
| Not NuSoap Server | |
| Is it possible!? | |
| Examples | |
Joined: 18 Jun 2008 |
Posts: 7 |
Location: India |
|
|
Posted: Fri Jun 20, 2008 4:03 am |
|
|
|
|
|
Hello Dimitri,
Thank you very much for the response. Its very kind of you.
Please find below the example (modified wherever needed
to hide the company data):
The Local WSDL File:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://www.testbooks.com/schemas/2005/06/messages" xmlns:intf="http://www.testbooks.com/schemas/2005/06/messages" xmlns:tns1="http://axis.frontend.bsi.testbooks.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.testbooks.com/schemas/2005/06/messages">
<wsdl:types>
<schema targetNamespace="http://axis.frontend.bsi.testbooks.com" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="getBSIBooksList" type="xsd:anyType"/>
</schema>
<schema targetNamespace="http://www.testbooks.com/schemas/2005/06/messages" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="getBSIBooksListReturn" type="xsd:anyType"/>
</schema>
</wsdl:types>
<wsdl:message name="getBSIBooksListResponse">
<wsdl:part name="getBSIBooksListReturn" element="impl:getBSIBooksListReturn"/>
</wsdl:message>
<wsdl:message name="getBSIBooksListRequest">
<wsdl:part name="part" element="tns1:getBSIBooksList"/>
</wsdl:message>
<wsdl:portType name="BSI">
<wsdl:operation name="getBSIBooksList">
<wsdl:input name="getBSIBooksListRequest" message="impl:getBSIBooksListRequest"/>
<wsdl:output name="getBSIBooksListResponse" message="impl:getBSIBooksListResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BSISoapBinding" type="impl:BSI">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getBSIBooksList">
<wsdlsoap:operation/>
<wsdl:input>
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="BSIService">
<wsdl:port name="BSI" binding="impl:BSISoapBinding">
<wsdlsoap:address location="http://000.000.000.00/cratos/ws/BSI"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions> |
The Php Code:
require_once('nusoap.php');^M
$wsdlfile = dirname(__FILE__)."/bsi.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$BoosRQ= '<BSI_BooksListRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" echoToken="0123"><Language>EN</Language><Credentials><User>'.$user.'</User><Password>'.$passwd.'</Password></Credentials></BSI_BooksListRQ>';
if(($client = new SoapClient($wsdlfile,true,"BSI"))) {
$rs1=$client->Call("getBSIBooksList",array($BooksRQ),"http://axis.frontend.bsi.testbooks.com");
//$rs1=$client->Call("getBSIBooksList",array($methodName=>$requestXML),"http://axis.frontend.bsi.testbooks.com");
if(@array_key_exists('faultcode', $rs1)) {
echo $rs1;
} else {
echo "Success";
}
}
|
The following is the request nusoap creates:
<?xml version="1.0" encoding="ISO-8859-1"?><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" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://axis.frontend.bsi.testbooks.com"><SOAP-ENV:Body><part><BSI_BooksListRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" echoToken="0123"><Language>EN</Language><Credentials><User>test</User><Password>test</Password></Credentials></BSI_BooksListRQ></part></SOAP-ENV:Body></SOAP-ENV:Envelope>
|
For the above request server responds with a 501 error.
The following is the request that server accepts:
<?xml version="1.0" encoding="ISO-8859-1"?><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" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://axis.frontend.bsi.testbooks.com"><SOAP-ENV:Body><tns1:getBSIBooksList><BSI_BooksListRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" echoToken="0123"><Language>EN</Language><Credentials><User>test</User><Password>test</Password></Credentials></BSI_BooksListRQ></tns1:getBSIBooksList></SOAP-ENV:Body></SOAP-ENV:Envelope>
|
Hope the above this help.
Kind Regards,
Sanjeev
|
|
|
| | |
| Working. | |
Joined: 18 Jun 2008 |
Posts: 7 |
Location: India |
|
|
Posted: Mon Jun 23, 2008 4:55 am |
|
|
|
|
|
Hello Dimitri,
Yes that fixed the problem. Thank you very much.
As modifying the wsdl file is not the right option and it'd be better to give the user
an extra flexibility, I have patched the nusoap.php which doesn't affect any existing
usages of nusoap.php.
I have added two variables to nusoap_base
$style='rpc' and $forceStyle=false
and updated the client->call method to
have an extra argument $forceStyle
One can use either of them to force the use of specified style overriding the wsdl
default style. One have to pass the namespace as the third parameter.
$client->style = 'rpc' (or document)
$client->forceStyle = true.
$client->call($method, $array, "namespace"); |
or
$client->call($method, $array, "namespace", '', false, null, 'rpc', 'literal', true); |
As I didn't find a way to attach any files to this thread, please find below the
patch:
--- nusoap-orig/nusoap.php 2008-06-24 15:04:32.000000000 +0530
+++ nusoap.php 2008-06-24 15:32:53.000000000 +0530
@@ -197,6 +197,24 @@
var $xmlEntities = array('quot' => '"','amp' => '&',
'lt' => '<','gt' => '>','apos' => "'");
+
+ /**
+ * Style to use for SOAP document
+ *
+ * @var string (can be one of rpc or document)
+ * @access public
+ */
+ var $style = "rpc";
+
+ /**
+ * Force the specified style or use the WSDL specified style
+ *
+ * @var boolean (true: forces the above given style.
+ * false: takes the one specified in WSDL)
+ * @access public
+ */
+ var $forceStyle = false;
+
/**
* constructor
*
@@ -6539,7 +6557,7 @@
* @return mixed response from SOAP call
* @access public
*/
- function call($operation,$params=array(),$namespace='http://tempuri_org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
+ function call($operation,$params=array(),$namespace='http://tempuri_org',$soapAction='',$headers=false,$rpcParams=null,$style='',$use='encoded', $forceStyle=false){
$this->operation = $operation;
$this->fault = false;
$this->setError('');
@@ -6571,7 +6589,14 @@
$this->endpoint = $this->forceEndpoint;
}
$namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace;
- $style = $opData['style'];
+
+ if($forceStyle || $this->forceStyle) {
+ $style = (empty($style))? $this->style : $style;
+ } else {
+ $style = $opData['style'];
+ }
+ if(empty($style)) $style = 'rpc';
+
$use = $opData['input']['use'];
// add ns to ns array
if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
|
May be we have to do something similar to give flexibility for user to override the wsdl defaults.
Hope this will be helpful for someone who is following this thread.
Thank you very much once again for taking time to update me on this thread.
Kind Regards,
Sanjeev
|
|
|
| | |
| SOAP Standards | |
Joined: 18 Jun 2008 |
Posts: 7 |
Location: India |
|
|
Posted: Sat Jun 28, 2008 11:37 pm |
|
|
|
|
|
Hello Dmitri,
Thank you for the update.
It might not conform to the standards, but might give
an extra flexibility to those users who might have to
deal with faulty implementations of the server . I will
submit the patch on the mailing list.
Kind Regards,
Sanjeev
|
|
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
|
|
|
| |