0

I have a .net web service that is standard SOAP, as well as I've added the POST/GET ability to. In .net I can consume the web service without any problems and when using the test POST page I can successfully use the web service as well. I've had a request from a php developer to use the web service which I thought would not be a problem at all, however he is unable to get a successful result. I have never used PHP so I don't have a test project I can even use for the php side of things. I believe it's the first web service he's ever used so he doesn't have a lot of experience himself.

So my questions are:

1) As a .net developer I'm stumped on how to even begin looking at the problem. I do not know if it's a problem in my web service or a problem in his php code. Because .net and POST work I'm inclined to believe it's something in his code, however I'm unable to test because I do not know php.

2) Is there some tag or something I need to do to allow php to correctly use my service?

3) Is there any tool I can use to check compatability with php?

4) Can someone with PHP knowledge look over his code and see if there are any obvious problems?

SOLVED: Please see working code in answer.

Essential
  • 23
  • 1
  • 6
  • Use `echo $client->__getLastRequest();` and show what it prints. Specifically, check that the three input params are present in the request. – MrCode May 15 '12 at 11:59
  • @MrCode I tried this, using a PHP script test page (http://writecodeonline.com/php/) and here is the result: 1db1c37d-b181-443e-8cfb-c4574c1245d955184d93-771a-44d1-ba7a-fd02fe1e15f5. Clearly there's only 2 guids present there. Sure seems like that could be the problem. Do you see anything wrong with the array decleration code? – Essential May 15 '12 at 14:43
  • `__getLastRequest()` should give you the entire XML for the request. You might need to view the source to see it in a browser (because it may hide the xml). Update the question with the full XML request, so we can see the whole thing. – MrCode May 15 '12 at 16:25
  • @MrCode Sorry, please see the original question for the xml request code. It's clearly missing 1 parameter. It appears to be dropping the first declared param, VendorID. Any ideas? – Essential May 15 '12 at 18:14
  • @MrCode I got it working! I started looking into the soap xml and looking up more php code and I was able to piece together working code. – Essential May 15 '12 at 22:33
  • You mentioned the following "and when using the test POST page I can successfully use the web service as well. " which make me thing that all the parameters to the webservice are primitive data type and not a complex object. If that is the case, do a view source on the test form and grab all the html code from
    . This should give you all the info that you need to do a basic http post from the php page. I do this with all of our partner that use php so they can consume it. You can also create a .aspx page that they can post to and then consume the webservice there.
    – atbebtg May 15 '12 at 23:05
  • @atbebtg Interesting and thank you for that suggestion. I'm going to look into your suggestion if nothing else but to know another way to do this. Thanks! – Essential May 16 '12 at 03:45

4 Answers4

1
$function = "soapcall"; 
$array =array("Param1" => "parameter1", "Param2" => "parameter2", "Param3" => "parameter3"); 

$client = new SOAPClient( 
'http://url.asmx?WSDL', 
array( 
    'location' => 'url.asmx?WSDL', 
    'trace' => 1, 
    'style' => SOAP_RPC, 
    'use' => SOAP_ENCODED, 
) 
);


$result = $client->__soapCall('soapcall', array("parameters"=>$array));

foreach( $result as $r) 
{   print $r."<br>";    }
Essential
  • 23
  • 1
  • 6
0

there's a certain lack of interoperability with WCF and other web services - this isn't just a PHP thing, Java libraries often fail to work with WCF web services too. There more information in many other SO questions - see the sidebar.

One thing you could try is SOAPUI (or from sourceforge) to call your web service 'interactively' which should help him figure out web services.

gbjbaanb
  • 51,617
  • 12
  • 104
  • 148
  • Thanks for the SOAPUI link, it looks like that will come in very handy to help diagnose this. – Essential May 15 '12 at 15:30
  • I have dl'd and installed SOAPUI and my web service has passed the WS-I compliance. I've also ran numereous tests/requests and everything seems to be working as intended. At this point I've got to assume that this is an issue with PHP not playing nicely with SOAP. – Essential May 15 '12 at 15:58
0

We use NuSoap for webservice calls in Php and it works very well.

David Mårtensson
  • 7,550
  • 4
  • 31
  • 47
0

.NET Service need to have http endpoints(adapter). https://bugs.php.net/bug.php?id=50698

Also sometime you need to have NTLM authorization Call webservice with NTLM authorization

Marcin Jaworski
  • 330
  • 2
  • 9