简体   繁体   中英

Consuming PHP webservice method with a boolean return value with .NET

I have a PHP SOAP (NuSOAP) web service method that returns a boolean value. I've executed the method in a 3rd party test application, and it seems to return the value fine. If I look directly at the XML message that's returned, it looks fine as well - returns "true" and "false" when it's supposed to.

However, when I write a sample application in .NET 2.0 to consume the web service method, it always returns false. If the return value is requested as a boolean, it's always false. If it's requested as a string, I get an empty string. Oddly enough, when I use a mock SOAP service to return exactly the same SOAP response, .NET is able to parse it correctly. So, my current theory is that the problem is not with the response itself, but with the headers - something is different about what PHP is doing.

Does anyone know what's going on here? Is it a known issue with PHP's SOAP implementation?

Thanks!

I'm not 100% sure on whether or not this is a PHP error, but I remember that I had to specifically encode the types using SoapVar($var, TYPE).

I wasn't using NuSOAP though, I think just PHP's inbuilt SOAP library.

If you're not doing this already it may be the cause of your problem. If you are, then I'm a little out of ideas!

It does sound like this issue is a miscommunication on the consumer end, but in general I would recommend that you ditch NuSOAP (really old!!) and use PHP's SOAP library. It is just way nicer and more powerful and it might just solve your problem by magic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM