notfalsedev / laravel-soap

A soap client wrapper for Laravel
MIT License
634 stars 122 forks source link

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://currencyconverter.kowabunga.net/converter.asmx?WSDL' : failed to load external entity "http://currencyconverter.kowabunga.net/converter.asmx?WSDL" #182

Open Rkant7767 opened 4 years ago

Rkant7767 commented 4 years ago

Hello sir,

I have used this package but, I am getting above mentioned error when trying to launch it.It seems that there is some issue with my configurations.Could you please help me with this????

nguyenhiepvan commented 4 years ago

i got this too :(

K2ouMais commented 4 years ago

I think this issue could be, because Soap isnt sending the user_agent.

I tried to set the user agent in ->options but it still doesnt work.

nguyenhiepvan commented 4 years ago

sloved

K2ouMais commented 4 years ago

Could you please tell us at least how you solved it?

lichtner commented 4 years ago

@nguyenhiepvan how did you solved it?

Rkant7767 commented 4 years ago

It has been resolved for me. I just needed to add setlocation and copy the wsdl url to it. e.g. $client->setLocation('http://www.webservicex.net/globalweather.asmx');

On Thu, 23 Apr 2020, 12:19 pm Nguyễn Văn Hiệp, notifications@github.com wrote:

i got this too :(

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/artisaninweb/laravel-soap/issues/182#issuecomment-618213110, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOO3TRCSRIF2EBEASEFFTODRN7QGPANCNFSM4MLI6KCQ .

wankimmy commented 4 years ago

image

solved !

jalvarado-it commented 3 years ago

I created this controller SoapController.php

<?php

namespace App\Http\Controllers;

use Artisaninweb\SoapWrapper\SoapWrapper;
use App\Soap\Request\GetConversionAmount;
use App\Soap\Response\GetConversionAmountResponse;

class SoapController
{
  /**
   * @var SoapWrapper
   */
  protected $soapWrapper;

  /**
   * SoapController constructor.
   *
   * @param SoapWrapper $soapWrapper
   */
  public function __construct(SoapWrapper $soapWrapper)
  {
    $this->soapWrapper = $soapWrapper;
  }

  /**
   * Use the SoapWrapper
   */
  public function show()
  {
    $response = 'empty';

    if(isset($this->soapWrapper)){
        $this->soapWrapper->add('Currency', function ($service) {
        $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->trace(true)
            ->options(['user-agent'=>'PHPSoapClient'])
            ->classmap([
            GetConversionAmount::class,
            GetConversionAmountResponse::class,
            ]);
        });

        $response = $this->soapWrapper->call('Currency.GetConversionAmount', [
        new GetConversionAmount('USD', 'EUR', '2014-06-05', '1000')
        ]);
    }
    echo $response;
  }
}

As the documentation mention I created the Request and Response PHP files Request \app\SOAP\Request

<?php

namespace App\Soap\Request;

class GetConversionAmount
{
  /**
   * @var string
   */
  protected $CurrencyFrom;

  /**
   * @var string
   */
  protected $CurrencyTo;

  /**
   * @var string
   */
  protected $RateDate;

  /**
   * @var string
   */
  protected $Amount;

  /**
   * GetConversionAmount constructor.
   *
   * @param string $CurrencyFrom
   * @param string $CurrencyTo
   * @param string $RateDate
   * @param string $Amount
   */
  public function __construct($CurrencyFrom, $CurrencyTo, $RateDate, $Amount)
  {
    $this->CurrencyFrom = $CurrencyFrom;
    $this->CurrencyTo   = $CurrencyTo;
    $this->RateDate     = $RateDate;
    $this->Amount       = $Amount;
  }

  /**
   * @return string
   */
  public function getCurrencyFrom()
  {
    return $this->CurrencyFrom;
  }

  /**
   * @return string
   */
  public function getCurrencyTo()
  {
    return $this->CurrencyTo;
  }

  /**
   * @return string
   */
  public function getRateDate()
  {
    return $this->RateDate;
  }

  /**
   * @return string
   */
  public function getAmount()
  {
    return $this->Amount;
  }
}

Response \app\SOAP\Response

<?php

namespace App\Soap\Response;

class GetConversionAmountResponse
{
  /**
   * @var string
   */
  protected $GetConversionAmountResult;

  /**
   * GetConversionAmountResponse constructor.
   *
   * @param string
   */
  public function __construct($GetConversionAmountResult)
  {
    $this->GetConversionAmountResult = $GetConversionAmountResult;
  }

  /**
   * @return string
   */
  public function getGetConversionAmountResult()
  {
    return $this->GetConversionAmountResult;
  }
}

Then i call it

Route::get('/soap',[SoapController::class, 'show']);

And I got this error too:

image

I really need to create a SOAP client, I need to create a SOAP client for a BizFlow POC

jalvarado-it commented 3 years ago

I founded a solution

Here is my controller

<?php

namespace App\Http\Controllers;

use Artisaninweb\SoapWrapper\SoapWrapper;
use App\Soap\Request\GetConversionAmount;
use App\Soap\Response\GetConversionAmountResponse;

class SoapController
{
  /**
   * @var SoapWrapper
   */
  protected $soapWrapper;

  /**
   * SoapController constructor.
   *
   * @param SoapWrapper $soapWrapper
   */
  public function __construct(SoapWrapper $soapWrapper)
  {
    $this->soapWrapper = $soapWrapper;
  }

  /**
   * Use the SoapWrapper
   */
  public function show()
  {
    $response = 'empty';
    $opts = array(
        'http' => array(
            'user_agent'=>'PHPSoapClient'
        )
    );
    $context=stream_context_create($opts);
    $wsdl='http://currencyconverter.kowabunga.net/converter.asmx?WSDL';
    $o=array(
        'stream_context'=>$context,
        'cache_wsdl'=>WSDL_CACHE_NONE
    );

    $a=$this->soapWrapper->add('servicio',function($service){
        $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->trace(true)
            ->options([
                'stream_context'=>stream_context_create([
                    'http' => array(
                        'user_agent'=>'PHPSoapClient'
                    )
                ]),
                'cache_wsdl'=>WSDL_CACHE_NONE
            ]);
        dump($service);

    });

    $this->soapWrapper->client('servicio',function($client){
        echo '<h3>Functions</h3>';
        dump($client->getFunctions());
        echo'<h3>call</h3>';
        dump($client->call('GetCurrencies',[]));
    });

/*
    if(isset($this->soapWrapper)){
        $this->soapWrapper->client(null,function($service){
            $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->options(['user-agent'=>'PHPSoapClient']);
        });

        $this->soapWrapper->add('Currency', function ($service) {
        $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->trace(true)
            ->options(['user-agent'=>'PHPSoapClient'])
            ->classmap([
            GetConversionAmount::class,
            GetConversionAmountResponse::class,
            ]);
        });

        //*$response = $this->soapWrapper->call('Currency.GetConversionAmount', [
        new GetConversionAmount('USD', 'EUR', '2014-06-05', '1000')
        ])
    }*/

    echo $response;
  }
}

And this is the invocation image

jalvarado-it commented 3 years ago

You can close it! The solution is in the options

$this->soapWrapper->add('servicio',function($service){
        $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->trace(true)
            ->options([
                'stream_context'=>stream_context_create([
                    'http' => array(
                        'user_agent'=>'PHPSoapClient'
                    )
                ]),
                'cache_wsdl'=>WSDL_CACHE_NONE
            ]);
        dump($service);

    });
charmtorio commented 2 years ago

Hi, using Laravel 9 and the WSDL url (http://currencyconverter.kowabunga.net/converter.asmx?WSDL) is not available anymore. Also adding 'user_agent' => 'PHPSoapClient' is not working anymore. Someone help?

Maerryham commented 2 years ago

Please all these are not working, still getting

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://currencyconverter.kowabunga.net/converter.asmx?WSDL' : failed to load external entity "http://currencyconverter.kowabunga.net/converter.asmx?WSDL"

siribanjoy commented 1 year ago

Updates? Still not working