Forum Moderators: coopster

Message Too Old, No Replies

Help Creating NuSOAP Request

Searched for literally 2 days, help is appreciated!

         

kazisdaman3

6:48 pm on Jun 27, 2008 (gmt 0)

10+ Year Member



Hey everyone, I have been trying diligently for 2 days to get this to work before asking for any help. I'm trying to create a PHP NuSOAP request similiar to this:


POST
https://global.marketing.ews.yahooapis.com/services/V4/LocationService
HTTP/1.0
Content-Type: text/xml; charset=utf-8
Content-Length: 987

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://marketing.ews.yahooapis.com/V4">

<soapenv:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>user</wsse:Username>
<wsse:Password>password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>

<license>35cf33e7-5ad1-3aa9-0593-346681f64eb0</license>
<masterAccountID>9901672</masterAccountID>
</soapenv:Header>

<soapenv:Body>
<getMasterAccountLocation/>
</soapenv:Body>
</soapenv:Envelope>

Does anyone have any ideas how to set this up, I think the wsse:Security part in the headers is what I just can't seem to get working correctly! Any help, would be much appreciated, thanks for helping me out, I truly appreciate this, I've been stuck for so long and tried to search before posting!

If someone could help me with the PHP syntax for forming the correct NuSoap Request, I'd be in debt to you!

cameraman

9:44 am on Jun 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm way far from being an expert on this - I just had to suffer through it myself once. I actually gave up on the namespace part and hacked a solution. I did some more looking at it this evening and I think you're looking at something along these lines:
$client = new soapclient('https://global.marketing.ews.yahooapis.com/services/V4/LocationService?wsdl',true);
$security = array('Username'=>'me','Password'=>'pass');
$params = array('Security'=>$security,'license'=>'35cf33e7-5ad1-3aa9-0593-346681f64eb0','masterAccountID'=>'9901672');
$response = $client->call('LocationService',$params);

Note that the endpoint, which is the first parameter in the constructor, has ?wsdl tacked on to the end of the service address - this causes the bugger to get the metadata for the service - basically, a template for the class to use to build the xml document.

I didn't put in all the parameters, just enough for you to get the idea. I don't have any way of running any tests because I don't have a service to play with and if I tried to write one I'd have no idea whether the problems lay in the server or the client ;). I also don't know if 'LocationService' is correct - hopefully you know the service name you're trying to access.

If playing with that for awhile gets you nowhere, it might be interesting to note that you can form the XML yourself and send it directly in the call method - you send it as a simple string that replaces the second parameter, which is an array above.

It also might be worthwhile to browse around and see if they have a non-soap method of doing what you want to do - I've found that to be true in a couple of cases.

kazisdaman3

6:24 pm on Jun 28, 2008 (gmt 0)

10+ Year Member



cameraman! Thank you so much, I really appreciate this you have no idea!

Thanks I will do all you have suggested to do and do my best to make it works, thanks so much again. -Wesley