Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What my problem is I have a .asmx webservice(.net webservice) in that one method name WriteLogInDB which accepts argument i.e object of a .net class. Now i want to call that WriteLogInDB method by passing an object from php. How can i call that method and how can i pass the object from php.

**My Attempts**
By using soap client call i call that method by passing an object with some data (PHP class object).But it reaches to webservice it became empty and i got a response from webservice WriteLogInDB method (object can't be null. In WriteLogInDB it first checks the object weather it is empty or not if it is empty it returns msg object can't be null. ) .
But i am not passing an empty object.

**My code**

$ini = ini_set("soap.wsdl_cache_enabled","0");
$url = "http://log.cocoonit.in/writelogsindbservice.asmx?WSDL";
//creating soap client
$client = new SoapClient($url, array("trace" => 1 , "exception" => 0));
$objLogParameter = new LogParameters(); // my php class
$objLogParameter->strLogMessage = $message." ".$extendedMessage;
$objLogParameter->strStackTrace = $preStackTrace;
$objLogParameter->strUser = "Osmosys";
$objLogParameter->strCustomer = "ws";
$objLogParameter->strPageOrModuleName = "calling ws";
$objLogParameter->strApplication = "OsmTest";
$objLogParameter->strSubscription = "test2";
$objLogParameter->EnumSeverity = "Error";
$objLogParameter->EnumLogType = "ErrorTest";

//calling webservice method by passing an object
$res = $client->WriteLogInDB($objLogParameter);

//In $res i got an stdClass obect (WriteLogInDB => object) in that object ,$StausCode = 0, $StatusMessage = object can not be null.



I tried in another way also like

$objLogParameter = new stdClass();
$objLogParameter->strLogMessage = $message;
$objLogParameter->strStackTrace = $preStackTrace;
$objLogParameter->strUser = "Osmosys";
$objLogParameter->strCustomer = "ws";
$objLogParameter->strPageOrModuleName = "calling ws";
$objLogParameter->strApplication = "OsmTest";
$objLogParameter->strSubscription = "test2";
$objLogParameter->EnumSeverity = "Error";
$objLogParameter->EnumLogType = "ErrorTest";


$res = $client->WriteLogInDB($objLogParameter);


One more way also i tried like before passing an object i encode (json_encode ) the object and then call the method.
Even though i got same result..
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900