tags:

views:

826

answers:

2

My company publishes a set of .NET webservices available via SOAP. I need to tie my PHP application into these, but I'm bumping up against a problem that I can't find a solution for. One of the services I need to access has a signature of Advertiser CreateAdvertiser ( Advertiser advertiser ).

How can I pass an instance of an object that I don't have (Advertiser)? I've tried creating an instance of stdClass() and assigning the required properties of the .NET Advertiser, but that's not flying. Somehow, I need to compose an object that the service will recognize and pass that along. Any ideas on how to go about that?

I'm using the SoapClient class for PHP, of course.

Much appreciated.

UPDATE: After a lot of trial and error, I've finally found that the first part of the problem is that no parameters are being passed - neither simple scalars nor complex types. I've tried using named params: array ( 'name1' => 'val1', 'name2' => 'val2' ) and unnamed, but a dump of __getLastRequest shows an empty method call:

...<SOAP-ENV:Body><ns1:CreateAdvertiser/></SOAP-ENV:Body>...

I need to solve that problem before worrying about the next one, I think.

A: 

I had to do this once. A client using PHP was having problems using a web service. (he was using NuSoap, I think) I used Fiddler to capture how the xml was coming across. Once we knew that, he could assemble the xml, add the soap envelope, adjust the content length header and successfully submit.

It is way too easy to create a web service that PHP or Java cannot use.

R Ubben
Oy. Just about the last thing I want to do is assemble SOAP-formatted XML by hand. I appreciate the suggestion, but will hope against hope that it doesn't come to that. :-)
Rob Wilkerson
+1  A: 

So the answer here, at least for the services I'm trying to call, is simple and painful. It just involves a lot of arrays.

$user = AdvertiserProxy->CreateAdvertiser ( 
   array (
      'advertiser' => array (
         'Name' => 'Advertiser Name',
         'IndustryCodeList' => array (
            'Agency',
            'Fortune 500'
         )
      )
   )
);

The advertiser "object" is just the sum of its parts.

Rob Wilkerson