-
how to consume Asp.net webservice from php client
over 9 years ago
-
over 9 years ago
Hello Jaiboon ,
There could be number of reasons for your code not working but can you please check you are accessing result from the web services is proper way because .NET returns an array object other then a simple string.So something like this will give error :
echo $client->Record(2,3); (Will give error like 'Object of class stdClass could not be converted to string in')
While print_r($client->Record(2,3)) will give you proper result.
Thus to gain access to actual result use :
echo $client->Record(2,3)->RecordResult;
-
over 9 years ago
Hi Jaiboon ,
Try to check the SOAP target url and SOAP action and check that both are correct.
If yes then the error can be from the data type mismatch. eg if you are using date at receiver end so the format must be exactly same as sender side. Cross check once more the format and data types of various fields.
-
over 9 years ago
Hello Jaiboon,
Please check that request parameter datatype should be the same as it is in .net web service
for example:- if response parameter is address and its datatype is "string" in .Net webservice so you must send address in a request parameter as a "string" datatype.
Please check and let me know if it works
Thanks
-
over 9 years ago
I have tried this code: require_once('php/lib/nusoap.php'); $client = new nusoap_client('http://210.212.23.51/rtpsappeal/service1.asmx?WSDL',true); $userKey = "Zxo7654IBN"; $applicationId = '040172192101500191'; $result = $clien - See more at: http://findnerd.com/users/content?value=Published#sthash.XQAxVppL.dpuf
-
over 9 years ago
Hello Jaiboon ,
There could be number of reasons for your code not working but can you please check you are accessing result from the web services is proper way because .NET returns an array object other then a simple string.So something like this will give error :
echo $client->Record(2,3); (Will give error like 'Object of class stdClass could not be converted to string in')
While print_r($client->Record(2,3)) will give you proper result.
Thus to gain access to actual result use :
echo $client->Record(2,3)->RecordResult;
-
over 9 years ago
Hello Jaiboon,
There could be many problems for this error. Eg sending wrong request parameters.
I will suggest you to check the format of request data you are sending to server.
Also some of the web services required username and password to call the service and if missing server will send you same message as above. I will suggest you to check the web services documentation and if username and password is required then below code will give you some idea about passing the authentication header with service call.
$client = new SoapClient("URL"); $headerBody = array( 'Username' => 'USERNAME', 'Password' => 'PASSWORD' ); $header = new SoapHeader('http://tempuri.org/', 'AuthHeader', $headerBody); $client->__setSoapHeaders($header); try { $result = $client->FUNCTION_NAME($REQUEST_DATA_ARRAY); return $result; } catch (Exception $exc) { echo "Caught soap fault error: ".$exc->getMessage()."\n"; }
Hope using above suggestion, your problem will be fixed.
-
over 9 years ago
Please provide the code packet you are trying.
-
over 9 years ago
Thanx everyone i got my issue resolved
-
-
over 9 years ago
I have taken string for userkey and applicationid. But then also error is coming. Pls help i m stuck at this point
-
-
over 9 years ago
I am getting the error now also. Pls Can anybody help me?
-
-
over 9 years ago
I am getting the following error by using the above posted code : Caught soap fault error: Server was unable to process request. ---> Input string was not in a correct format.
-
11 Answer(s)