working with Complex .net types in php
[email protected] (ryber)
| Newsgroups | php.soap |
|---|---|
| Message-ID | <[email protected]> |
Greeting, I'm trying to consume a .net web service with PHP that uses complex
types. I think Im missing something fundamental here. My first trial is to
get a application "user" object from the service, and then pass it back and
have it save. I can do this perfectly in .net and coldfusion. However when I
do it in PHP I get an error because it appears that the object is not
getting passed. Let me show you:
First I set up the client and get the object:
---------------------------------------------
$client = new
SoapClient("http://localhost/client/webservices/webservices.asmx?WSDL",
array('login' => "xxxx",
'password' =>
"yyyyy",
'trace' => 1));
$params = array('userName'=>"ryber");
$MyUser = $client->LoadUser($params);
---------------------------------------------
here is the soap output:
Request :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://geolearning.com/geonext/webservices/"><SOAP-ENV:Body><ns1:LoadUser><ns1:userName>[email protected]</ns1:userName></ns1:LoadUser></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><LoadUserResponse
xmlns="http://geolearning.com/geonext/webservices/"><LoadUserResult><Status>Active</Status><CreationTime>2007-07-18T19:40:55</CreationTime><ModifiedTime>2007-07-22T08:45:16</ModifiedTime><FirstName>Bob</FirstName><MiddleInitial>B</MiddleInitial><LastName>Snazzypants</LastName>[email protected]<StreetAddress>1234
1st st</StreetAddress><City>Bolder</City><State>MN</State><Country>United
States</Country><PostalCode>90210</PostalCode><PostalCodeType>APO</PostalCodeType><Telephone>515.555.7654</Telephone><Extension>42</Extension><LocationName>Minneapolis
Conv
Center</LocationName><StartDate>1985-03-55T00:00:00</StartDate><UserName>[email protected]</UserName><Password
/><SupervisorUserNames><anyType
xsi:type="xsd:string">[email protected]</anyType><anyType
xsi:type="xsd:string">[email protected]</anyType></SupervisorUserNames><Groups
/><RoleNames><anyType xsi:type="xsd:string">Administrator</anyType><anyType
xsi:type="xsd:string">Student</anyType></RoleNames><DefaultRoleName>Administrator</DefaultRoleName><ExternalId>04a0a102-c8dc-481c-aa14-b234bc10acd6</ExternalId><CustomUserAttributes
/><CustomSelectUserAttributes
/></LoadUserResult></LoadUserResponse></soap:Body></soap:Envelope>
looks mostly good, $MyUser gets turned into a nice PHP dataset. its a object
called stdClass that contains structures, arrays and other stdClass objects
(how come these classes are not named properly?)
now...without doing anaything to it I pass it right back to .net to save:
-----------------------------------------------
//strip off the LoadUserResult section. note Ive tried this leaving it on as
well!
$justuser = $MyUser->LoadUserResult;
$params = new SoapParam($justuser,"User");
$client->UpdateUser($params);
-----------------------------------------------
here is the result. note now the "UpdateUser" section in the request is
empty! why did my object not serialize into XML?!!
Request :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://geolearning.com/geonext/webservices/"><SOAP-ENV:Body><ns1:UpdateUser/></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>System.Web.Services.Protocols.SoapException:
Server was unable to process request. ---> System.NullReferenceException:
Object reference not set to an instance of an object.
at Geolearning.Webservice.WebServices.UpdateUser(User user)
--- End of inner exception stack trace ---</faultstring><detail
/></soap:Fault></soap:Body></soap:Envelope>
--
View this message in context: http://www.nabble.com/working-with-Complex-.net-types-in-php-tf4126929.html#a11736176
Sent from the Php - Soap mailing list archive at Nabble.com.