Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • how to consume Asp.net webservice from php client

    • 2
    • 2
    • 0
    • 11
    • 0
    • 0
    • 0
    • 469
    Answer it

    i want to fetch data from asp.net webservice from php client. WHile doing that i got an error.

    'faultstring' => string 'Server was unable to process request. ---> Input string was not in a correct format.' (length=84).

    I am using SOAP

 11 Answer(s)

  • 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;

  • 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.

  • 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

  • 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

  • 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;

  • 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.

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: