Avatar billede artico Novice
08. juni 2016 - 19:06 Der er 14 kommentarer

SOAP

Jeg forsøger at opdatere en SOAP forbindelse til e-conomic, denne kode har virket fint, 

class economic{
    protected $client      = null;
    private $wsdlURL        = 'https://www.e-conomic.com/secure/api1/EconomicWebservice.asmx?WSDL';
    private $trace          = 1;
    private $exceptions    = 1;

    public function __construct(){
        $this->client = new SoapClient($this->wsdlURL, array('trace' => $this->trace, 'exceptions' => $this->exceptions));
        $this->client->Connect(array('agreementNumber' => AGREEMENTNUMBER, 'userName' => USERNAME, 'password' => PASSWORD));
    }

    public function __destruct(){
        $this->client->Disconnect();
    }
}

Men nu kræves 'X-EconomicAppIdentifier, og jeg kan ikke få forbindelse, eller en fejlmeddelelse :-(

$client = new SoapClient ( "https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?WSDL", [
'stream_context' => stream_context_create(['http' => ['header' => 'X-EconomicAppIdentifier: YOUR APP IDENTIFIER']])
]);

Er der nogle gode forslag til hvordan jeg kombinere ovenstående kode?
Avatar billede arne_v Ekspert
08. juni 2016 - 19:10 #1
Gaet:

$this->client = new SoapClient($this->wsdlURL, array('trace' => $this->trace, 'exceptions' => $this->exceptions,'stream_context' => stream_context_create(array('http' => array('header' => 'X-EconomicAppIdentifier: YOUR APP IDENTIFIER')));
Avatar billede artico Novice
08. juni 2016 - 19:28 #2
Har forsøgt med denne kode (selvføli med mit eget APP ID)

class economic{
    protected $client      = null;
    private $wsdlURL        = 'https://www.e-conomic.com/secure/api1/EconomicWebservice.asmx?WSDL';
    private $trace          = 1;
    private $exceptions    = 1;

    public function __construct(){
        $this->client = new SoapClient($this->wsdlURL, array('trace' => $this->trace, 'exceptions' => $this->exceptions,'stream_context' => stream_context_create(array('http' => array('header' => 'X-EconomicAppIdentifier: YOUR APP IDENTIFIER')));
        $this->client->Connect(array('agreementNumber' => AGREEMENTNUMBER, 'userName' => USERNAME, 'password' => PASSWORD));
    }

    public function __destruct(){
        $this->client->Disconnect();
    }
}

Men stadig ingen fejl, eller forbindelse :-(
Avatar billede arne_v Ekspert
08. juni 2016 - 19:49 #3
Viser du alle fejl?
Avatar billede artico Novice
08. juni 2016 - 20:05 #4
No.. kun en flot hvis side :-(
Hvordan jeg jeg få en eller anden respons ud af ovenstående ?
Avatar billede arne_v Ekspert
08. juni 2016 - 20:07 #5
Du skal jo evt. bede PHP om at vise alle fejl. Er nogen gange slaaet fra som standard.
Avatar billede artico Novice
08. juni 2016 - 20:28 #6
Selvføli, så fik jeg nogle fejl frem :-)

det er måden at $this linjerne slutter på:

fejl: Parse error: syntax error, unexpected ';'

$this->client = new SoapClient($this->wsdlURL, array('trace' => $this->trace, 'exceptions' => $this->exceptions,'stream_context' => stream_context_create(array('http' => array('header' => 'X-EconomicAppIdentifier: YOUR APP IDENTIFIER')));
        $this->client->Connect(array('agreementNumber' => AGREEMENTNUMBER, 'userName' => USERNAME, 'password' => PASSWORD));
Avatar billede arne_v Ekspert
08. juni 2016 - 20:39 #7
Du skal nok igang med at taelle parenteser!
Avatar billede arne_v Ekspert
08. juni 2016 - 20:40 #8
$this->client = new SoapClient($this->wsdlURL, array('trace' => $this->trace, 'exceptions' => $this->exceptions,'stream_context' => stream_context_create(array('http' => array('header' => 'X-EconomicAppIdentifier: YOUR APP IDENTIFIER')));

->

$this->client = new SoapClient($this->wsdlURL, array('trace' => $this->trace, 'exceptions' => $this->exceptions,'stream_context' => stream_context_create(array('http' => array('header' => 'X-EconomicAppIdentifier: YOUR APP IDENTIFIER')))));

maaske. Hvis jeg kan taelle til 5.
Avatar billede artico Novice
08. juni 2016 - 21:01 #9
Yessss... !!! Nu er der hul igennem.. meeeen så aligevel ikke :-( Og jeg har den rette APP ID... mystisk

Economic.Api.Exceptions.AuthorizationException(E03100): You need to include an X-EconomicAppIdentifier header when not connecting with the Token Based model. Read more at https://www.e-conomic.com/developer. (id=ad7776fd-5178-4d42-aa6b-126ba17681d4)
Avatar billede arne_v Ekspert
09. juni 2016 - 03:06 #10
Jeg tror at jeg er loebet toer for ideer.

Kan du sniffe net traffiken og se hvad der bliver sendt i request?
Avatar billede artico Novice
09. juni 2016 - 14:25 #11
arne_v, Kan du hjælpe mig uden for exp.dk ?
Avatar billede arne_v Ekspert
10. juni 2016 - 03:28 #12
Det tvivler jeg paa vil kunne lade sig goere.
Avatar billede artico Novice
10. juni 2016 - 10:25 #13
Oki, bare i orden.... Jeg har fået dette til at virke på en seperat side:

$wsdlUrl = 'https://api.e-conomic.com/secure/api1/EconomicWebservice.asmx?WSDL';

    $client = new SoapClient(
        $wsdlUrl,
        array(
            "trace" => 1,
            "exceptions" => 1,
            "features" => SOAP_SINGLE_ELEMENT_ARRAYS
        )
    );
    $client->ConnectWithToken(
        array(
            'token'     => $_REQUEST['agreementGrantToken'],
            'appToken'    => $_REQUEST['appSecretToken']
        )
    );

Men når jeg forsøger at sætte det ind i mit system, på denne måde :


class economic{
    protected $client      = null;
    private $wsdlURL        = 'https://api.e-conomic.com/secure/api1/EconomicWebservice.asmx?WSDL';

    public function __construct(){

    $this->$client = new SoapClient(
      $wsdlUrl,
      array(
        "trace" => 1,
        "exceptions" => 1,
        "features" => SOAP_SINGLE_ELEMENT_ARRAYS

      )
    );

$this->$client->ConnectWithToken(
  array(
    'token'     => GRANTTOKEN,
    'appToken'    => APPSECRETTOKEN
  )
);

Så får jeg denne fejl:

SoapClient::SoapClient() [soapclient.soapclient]: 'uri' option is required in nonWSDL mode

Hvad gør jeg forkert?
Avatar billede arne_v Ekspert
13. juni 2016 - 02:13 #14
Svaert at sige. De to stykker kode ser jo meget ens ud!!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester