WSDL reading shows strange first character with php - php

I'm reading a wsdl for SOAP connection :
https://api3.popfax.com/index.php?service=Popfax&wsdl
Other clients (mobile apps, desktop software, ...) are using it and have been doing so for a long time.
When I try to construct a SoapClient from it, I get :
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://api3.popfax.com/index.php?service=Popfax&wsdl' : Start tag expected, '<' not found in D:\Dev\test\sendfax.php:32 Stack trace: #0 D:\Dev\test\sendfax.php(32): SoapClient->SoapClient('https://api3.po...') #1 {main} thrown in D:\Dev\test\sendfax.php on line 32
So I wrote this to test what I got :
$wsdl = 'https://api3.popfax.com/index.php?service=Popfax&wsdl';
$bip = file_get_contents($wsdl);
var_dump($bip);
And the result is string with on the first line :
'ï<?xml version="1.0" encoding="UTF-8"?>
And every time I reload that test script, the first character is different...
Any idea why ?

It's working fine for me. Have you tried using a simple text editor and just saving your code snippet in it, saving it with a .php suffix in your web root and calling it from localhost? (that's what I did)
It may be that the editor you're using has an encoding issue (just a huge guess).

Related

PHP Error : Parsing WSDL: Couldn't load from https://

I'm pretty new at SOAP, but i didn't think this problem was going to give me such a headache. :-)
I have a WSDL at :
https://qas.sanitel.be/int/QAS_Sanitel_ExtInterfacingSvcs_v2/SanitelServices.asmx?wsdl
Seems to be OK, but it's over https. i think that's where my problem is.
I wrote several PHP scripts i found here on stackoverflow and google to get at least a function list, but anything i try gives me the same error :
I put the script on a wamp server, external host, external with SSL..
( ! ) Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://qas.sanitel.be/int/QAS_Sanitel_ExtInterfacingSvcs_v2/SanitelServices.asmx?wsdl=wsdl1' : failed to load external entity "https://qas.sanitel.be/int/QAS_Sanitel_ExtInterfacingSvcs_v2/SanitelServices.asmx?wsdl=wsdl1" in C:\wamp\www\sanitel.php:25 Stack trace: #0 C:\wamp\www\sanitel.php(25): SoapClient->SoapClient('https://WS4SNTR...', Array) #1 {main} thrown in C:\wamp\www\sanitel.php on line 25
I have the credentials , tried several authentications, everything gives me this error...
anyone see something i don't ? Thanks a lot !

cannot connect to a soap api with php

I'm trying to access this URI: http://143.166.84.118/services/assetservice.asmx?WSDL (Dell warranty info)
In Windows Powershell I can do this no problem:
$service = New-WebServiceProxy -Uri http://143.166.84.118/services/assetservice.asmx?WSDL
But in PHP:
$DELL_URL = "http://143.166.84.118/services/assetservice.asmx?WSDL"; //Access webproxy by IP
$soap = new SoapClient($DELL_URL);
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://143.166.84.118/services/assetservice.asmx?WSDL' in C:\path\to\my\script.php:25 Stack trace: #0 C:\path\to\my\script.php(25): SoapClient->SoapClient('http://143.166....') #1 {main} thrown in C:\path\to\my\script.php on line 25
What am I doing wrong in php? I know the URL works cause it works with powershell.
As per Pete's suggestion I went to http://143.166.84.118/services/assetservice.asmx?WSDL and downloaded a local copy of the file then did this which worked:
$soap = new SoapClient($wsdlfilepath);
Do I always have to download a local copy of the file when using php?
edit: Didn't make any changes but now I'm getting "Uncaught SoapFault exception: [Client] looks like we got no XML document in..." error. Should I be worried about this? You can view the wsdl file by going to the link. Are there problems with it or extra white space? I didn't see any.

Cant connect to orange m2m using soap

I am trying to create a soap connection using the standard php soap client and I believe it is all correctly coded, however I am receiving this error :
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://m2mconnect.orange.co.uk/orange-soap/services/MessageServiceByCountry?wsdl' : Start tag expected, '<' not found in C:\wamp\www\php\run.php:16 Stack trace: #0 C:\wamp\www\php\run.php(16): SoapClient->SoapClient('https://m2mconn...') #1 {main} thrown in C:\wamp\www\php\run.php on line 16
From what I have found online it seems one problem may be to do with the ports, however im not sure which ports to check/use or how to.
Im also unsure if it is something to do with my internet connection as it is a little strange being from one router to another.
Here is my code:
$client = new SoapClient("https://m2mconnect.orange.co.uk/orange-soap/services/MessageServiceByCountry?wsdl");

SOAP service error

When I upload my webservice files to a live server it does not work. It was working on localhost. How can I fix this problem?
Error message
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing
WSDL: Couldn't load from
'http://openinvite.biz/iphoneservice/server2.php' : Premature end of
data in tag html line 2 in
D:\Hosting\7340680\html\iphoneservice\test.php:102 Stack trace: #0
D:\Hosting\7340680\html\iphoneservice\test.php(102):
SoapClient->SoapClient('http://fomlatong.com/server.php') #1 {main}
thrown in D:\Hosting\7340680\html\iphoneservice\test.php on line 102
You should probably use the WSDL version as opposed to the HTML one.
Change your URL to http://openinvite.biz/iphoneservice/server2.php?wsdl
The list of methods for that service appears to be
syncvents
getEvents
getAllEvents
searchPlaces
rsvpEvent
searchByCity
EditEvent
I'm not sure why you expect there to be a call() method.
Instead of using "soapclient" use "nusoap_client"

Fatal error: Uncaught SoapFault exception: [WSDL]

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.
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.
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.
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 ";"
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)

Categories