About the parameter passing problem of Web Service SOAP interfaces written by PHP in other languages

Source: Internet
Author: User
Tags soap wsdl

About PHP calls to other languages written by the Web Service SOAP Interface parameter transfer problem, the need for friends can refer to.


PHP calls Java-written SOAP interface experience:


Scenario One:


Java is receiving parameters as an array, and I use the following methods:


Method One:


Require_once Root_path. '/libraries/nusoap/nusoap.php ';//introduction of NUSOAP Class library file
$client = new Nusoap_client ("$WSDL _url", true);
$client->decode_utf8 = false;
$client->soap_defencoding = "UTF-8";//java receive is the use of utf-8, set to Utf-8, to prevent garbled
$arr =array ("param1" = $param 1, "param2" = $param 2);//Parameters passed
$result = $client->call (' reserve_save2 ', $arr);


if ($client->fault) {
Success
} else {


Failed


}


This scenario can also be called using the following three methods:



$client = new SoapClient ($WSDL _url);


Method Two, $client->functionname ($param 1, $param 2);


Method Three, $client->__soapcall ("functionname", Array ($param 1, $param 2));


Method Four, $client->__soapcall ("functionname", Array ("param1" and "= $param 1," param2 "= + $param 2));


Scenario Two:


Java is to receive parameters in the form of a string, method one debug unsuccessful, after a lot of attempts to find this post (http://blog.163.com/shihua_23/blog/static/2333759420108213340651/) , tried the inside of the method, finally succeeded, immediately burst into tears, very grateful to the author. Here's how:


Method Five:


$soap = new SoapClient ("$WSDL _url"
);


$param = Array ("Data" = "<request><cardtype>15</cardtype><cardnumber>88888888") </cardnumber><telephone>18511111111</telephone><name> Small Stars </name></Request> " );//Note: This must be a two-dimensional array, and the key value of the second dimension must be a string of the XML structure to be passed by the Data,value value.


$result = $soap->__soapcall (' functionname ',
$param);


The content of the article I refer to is posted here:


Links: http://blog.163.com/shihua_23/blog/static/2333759420108213340651/



When PHP calls C # to write a SOAP interface method that requires passing parameters, the following three methods fail to pass:


$client = new SoapClient ($WSDL _url);


1, $client->functionname ($param 1, $param 2);


2, $client->__soapcall ("functionname", Array ($param 1, $param 2));


3, $client->__soapcall ("functionname", Array ("param1" and "= $param 1," param2 "+ $param 2));



The correct method is to pass the parameter as a two-dimensional array, as follows:


$param _ary =array (Array ("param1" = $param 1, "param2" + $param 2));


$client->__soapcall ("functionname", $param _ary);


PHP does not need to pass a two-dimensional array if it calls the SOAP server that PHP writes itself.


The reason is unknown, unknown origin ....

About the parameter passing problem of Web Service SOAP interfaces written by PHP in other languages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.