2

I'm having trouble calling a web service I've set up from PHP. The obfuscated adress http://XXX.XXX.XXX.XXX/test.asmx?wsdl in the error message below returns a valid WSDL. I've successfully tried to call it as a web service using a VB.net client, but when I call it from PHP on Debian I get the following message:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:
  Couldn't load from 'http://XXX.XXX.XXX.XXX/test.asmx?wsdl'
  in /var/www/domain/mywebsite.com/public_html/catalog/fomeus/orders.php:101

Stack trace:
  #0 /var/www/domain/mywebsite.com/public_html/catalog/fomeus/orders.php(101):
    SoapClient->SoapClient('http://XXX.XXX.XXX.XXX/', Array) #1 {main} thrown
    in /var/www/domain/mywebsite.com/public_html/catalog/fomeus/orders.php
    on line 101

What could the problem be? I've included my code for the web service and the PHP client below.

Web Service:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
...
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class WebService1
Inherits System.Web.Services.WebService 
    <WebMethod()> _
    Public Function HelloWorld() As String
        Return "Hello World"
    End Function
End Class

PHP client:

require_once($_SERVER['DOCUMENT_ROOT']."/catalog/fomeus/includes/soap/nusoap.php");

$objClient = new soapclient("http://XXX.XXX.XXX.XXX/test.asmx?wsdl",
    array('trace' => 1, 'exception' => 0, 'cache_wsdl' => 0));

print_r($objClient -> HelloWorld());

I'm using PHP version 5.2.6 if that's of any help. I've been going through plenty of posts in different forums trying to figure out what the problem is. Many people have had the same issue, but none of the solutions I've found so far work for me. Any help would be greatly appreciated.

Tim Stone
  • 19,119
  • 6
  • 56
  • 66
Daniel
  • 21
  • 1
  • 1
  • 2
  • I have no clue what this may be, but, is there any possibility for you to try nuSOAP? – Ignacio Mar 10 '11 at 01:37
  • try wrapping a try..catch block around line where you create the SoapClient object. Dont forget the catch should be for a type of SoapFault - i.e. catch (SoapFault $e){} rather than catch (Exception $e) {} Inside the catch, either query the exception fields, (getMessage, etc) or var_dump the exception, and then post what it tells you. – Stephen Mar 10 '11 at 03:44
  • Where it reads "exception" shouldn't it read "exceptions"? – Edson Medina Mar 12 '11 at 14:21

4 Answers4

1

Another option to look at is cURL. You can create your payload as an XML string and send it to the same URL using cURL. You would then need to capture the response code and process as appropriate. When I had issues with SOAPClient, I moved to cURL - works like a charm.

Tash Pemhiwa
  • 7,590
  • 4
  • 45
  • 49
0

try to turn on php_soap.dll and php_openssl.dll in your php.ini. Located in the apache folder \apache\apache2.4.2\bin

remove the ";"

0

Adding index.php worked for me working on php application

$client = new SoapClient('http://www.domain.com/api/v2_soap/?wsdl'=1)

$client = new SoapClient('http://www.domain.com/index.php/api/v2_soap/?wsdl'=1)
Mukesh
  • 7,630
  • 21
  • 105
  • 159
0

If you're using nusoap (php 5.2 has a native soapclient, which I prefer), the first thing I see is your arguments. Argument #2 for nusoap's soapclient constructor should be boolean TRUE here, if you're using the WSDL, and not an array. Try:

$objClient = new soapclient("http://XXX.XXX.XXX.XXX/test.asmx?wsdl",true);
print_r($objClient->HellowWorld());

That's how i've been able to work with wsdl in the past.

If you're using the native client, and having problems with the wsdl, you can always bypass it and make straight calls, like so:

$objClient = new soapclient(null,array('uri'=>'http://xxx/test.asmx','location'=>'http://xxx/test.asm'));
$objClient->__call('HelloWorld',array());

That should work, but isn't as easy to navigate as wsdl.

Warren Krewenki
  • 3,523
  • 2
  • 17
  • 11
  • not sure about original poster, but I am using the natie php soap client – Zachary K Mar 10 '11 at 16:09
  • The most success i've had with with the native php soapclient would be done this way: $objClient = new soapclient(null,array('uri'=>'http://xxx/test.asmx','location'=>'http://xxx/test.asmx')); and then calling your method via $objClient->__call('HelloWorld',array()); – Warren Krewenki Mar 10 '11 at 18:36
  • 1
    What I ended up doing is requesting the wsdl file with file_get_contents, caching it locally and then using it with SoapClient. That way I can check if it is valid XML and bypass the problem (kind of ugly but it works) – Zachary K Mar 10 '11 at 19:43