How to implement PHP SoapClient using Soap Endpoint instead of using WSDL? - php

I have a requirement to write Soap Client in PHP to call a remote web service and get information. For that I got the Soap End Point URL which doesn't seems to be a WSDL.
I got the WSDL file in the IEPD document set for that Soap services.
When I tried to create new instance of the SoapClient using the End Point it is throwing below error.
"Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://...' : failed to load external entity "https://.." in..."
Can you please help me how should I find WSDL url using an endpoint? or is there any other way I can call the Soap using this end point without getting this error?
To add more reference, I have received the complete documentation of the SOAP webservice in a IEPD document.
Thanks

I suggest you have a look at PHP SoapClient documentation. Start with constructor function SoapClient::SoapClient. There are examples of non-WSDL usage

Related

Fatal error: Uncaught SoapFault exception: [WSDL] in php

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing
WSDL: Couldn't load from "url" failed to load external entity.
I am getting below error when used SoapClient in the code. How to resolve this?
You should double check the URL to the SOAP service you require, and that it does indeed serve a wsdl (add ?wsdl to the end of the URL and inspect in a browser).
It sounds like your SOAP Service URL is missing a WSDL (service discovery) or is not finding a valid SOAP endpoint.
If you care to share your SOAP URL I can provide example or I/others might be able to help more.
Could also be character encoding or User Agent filtering on the SOAP endpoint, have a read of this question : SOAP-ERROR: Parsing WSDL: Couldn't load from - but works on WAMP

Magento API URL doesn't exist

I'm trying to setup a Magento API, but when I try to access the API URL I get a 404
For example, http://localhost/magento/api or http://localhost/magento/api/?wsdl go nowhere.
So when I try to connect to the server with the SoapClient I always get an error like this:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/magento/api/soap/?wsdl' : failed to load external entity "http://localhost/magento/api/soap/?wsdl" in /var/www/html/magento/soapclient.php:3 .
In fact, when I can't open the WSDL XML with the browser nor access the /api endpoint.
Do I have to do anything else before get ready to work with the SOAP API?
I think that you already solve your problem, but just to document. If you does not use CURL URL, you need to use the path to your WSDL using the
link: http://magentohost.com/index.php/api/soap/?wsdl

Parsing Schema got error when using PHP SoapClient

I 'm trying to use PHP SoapClient to consume eBay web service. Just following the eBay official sample:
$client = new SoapClient('http://developer.ebay.com/webservices/latest/ebaysvc.wsdl');
I get an error as below:
SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: unexpected in simpleType in E:\xampp\htdocs\mysite\system\application\libraries\Ebaysvc.php:102 Stack trace: #0
Does anyone know how to solve this?
Please use this url for the wsdl http://developer.ebay.com/webservices/753/eBaySvc.wsdl
I don't knew why the changed the url. Thank to Pakistan for that Post http://www.adeelsarfaraz.com/how-to-remove-the-fatal-error-soap-error-parsing-schema-unexpected-in-sequence-error/

Using PHP SoapClient, Trying to Chande XSD from http://localhost to http://mysite.com

I am trying to consume a WSDL from WCF using PHPs SoapClient. When using the following code
$client = new SoapClient('http://subdomain.xxxxxxx.com:7575/?WSDL');
I get the following error :
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost:7575/?wsdl=wsdl0' : failed to load external entity "http://localhost:7575/?wsdl=wsdl0"
For the service configuration file for the WSDL the specific port that the WSDL is using, specifies:
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:7574" />
<add baseAddress="http://localhost:7575" />
</baseAddresses>
</host>
The problem is that the WSDL is redirecting to http://localhost:7575 for the wsdl=wsdl0 file... then all the XSD locations are also listing http://localhost:7575.... is there a PHP Soap function that I can use to change that to http://subdomain.xxxxxxx.com:7575/?wsdl=wsdl0
If you have control of the WCF service, it may be easier to configure it to produce "flattened" WSDL. This SO question & answer explains how to configure it to a single WSDL document.
If that isn't possible, may be you can have them (or possibly by you, locally) manually construct a single WSDL document and have them host it on their site so your PHP client can consume it as-is.

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