Re: working with Complex .net types in php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am using webservice.
Currently i have hardcoded my username and password in the code.
Is there any alternative to using password directly here?




ryber wrote:
> 
> 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>ryber@geolearning.com</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>snazzypants@nothing.com<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>ryber@geolearning.com</UserName><Password
> /><SupervisorUserNames><anyType
> xsi:type="xsd:string">3ddepthead.techs@nothing.com</anyType><anyType
> xsi:type="xsd:string">3dfbfs.mball@nothing.com</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. ---&gt;
> 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://old.nabble.com/working-with-Complex-.net-types-in-php-tp11736176p34989458.html
Sent from the Php - Soap mailing list archive at Nabble.com.


-- 
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux