Problems connecting to webservice

Help
Bjorn
2010-04-28
2013-06-06
  • Bjorn

    Bjorn - 2010-04-28

    Hi,

    I need to access a webservice at a clients supplier which spits out the amount of stock for a product when supplied the id. The information about the webservice is here : http://www.elektroskandia.se/Resurser/Dokument/Filer/Integration_med_Elektroskandias_Internetbutik.pdf but in Swedish. This is what it says:

    "The webservice is at https://www.elektroskandia.se/service/ExternKundService.asmx
    Access is done through https as it requiers username and password for verification
    The following functions are available in the webservice:
    Name: GetAvailableStock
    Parameters: UserId (string), is username, Pwd (string), is password, ItemNo (string), is item number"
    

    At first I used this code from one of the samples (a bit shortened):

    $client = new nusoap_client('https://www.elektroskandia.se/service/ExternKundService.asmx?WSDL', 'wsdl',
    $err = $client->getError();
    $param = array('UserId'=>'xxxUsernamexxx','Pwd'=>'xxxPasswordxxx','ItemNo'=>$Article_ID);
    $result = $client->call('GetAvailableStock', array('parameters' => $param), '', '', false, true);
    

    and it worked fine. However - then the company with the webservice made some changes and, as they said "turned off GET for WSDL but SOAP should still work". Well, they lost me there :/. I started to get an error messange and realized I had to redo the code. However - I can't seem to get it working at all …

    I tried:

    $useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0';
    $client = new nusoap_client("https://www.elektroskandia.se/service/ExternKundService.asmx", false,
                            $proxyhost, $proxyport, $proxyusername, $proxypassword);
    $client->setCredentials('xxxUsernamexxx', 'xxxPasswordxxx','basic');
    $err = $client->getError();
    $client->setUseCurl($useCURL);
    // This is an archaic parameter list
    $params = array(
        'ItemNo'=>'704301'
    );
    $result = $client->call('GetAvailableStock', $params, 'http://elektroskandia.se/service/GetAvailableStock', 'http://elektroskandia.se/service/GetAvailableStock');
    

    but get the reply that username/password is wrong (it is not, that has been triple-checked). If I choose digest/ntlm/certificate as setCredential-type it doesn't work at all (HTTP Error: Unsupported HTTP response status 400 Bad Request (soapclient->response has contents of the response)).

    I'm a bit lost here as none of the samples seem to work and I'm not familiar enough with webservices/SOAP to realize where to start looking. As I get the authentication-error it does point to the fact that something is wrong in the way I try to authenticate myself.

    Anyone who can give me some push in the right direction? Do you need more debug-info? I can post all the request/response/debug info from the sample I've worked with.

    Thanks very much in advance.

     
  • Scott Nichol

    Scott Nichol - 2010-04-28

    Is this your sample?  http://endre.net/soap/samples/elektro.php 

    Chrome found it for me.  If so, it looks like you have something working.  It not, I can explain the code you should use to get this behavior.

     
  • Bjorn

    Bjorn - 2010-04-28

    Actually that was an old version that I've forgotten. I've updated that example with the latest version of nu-soap as well as the latest code I tried. The result is the same though. Under result you get "Wrong username/Password" which suggests to me that I do indeed connecto to the webservice but the authentication seems to fail.

     
  • Scott Nichol

    Scott Nichol - 2010-04-29

    Yes, the debug that prints indicates that you send a SOAP request and get a SOAP response with the value Fel användare/lösenord as the result.  Perhaps they have taken your username/password out of their system?  BTW, the sample shows the username and password you used.

     
  • Bjorn

    Bjorn - 2010-04-29

    So it at least seems that the SOAP request and response are going through without any errors.
    What I was a bit curious about is that they say "Access is done through https as it requiers username and password for verification". Am I right that this is a reason why I would use "setCredentials()"?

    BTW - thanks for the help. I really appreciate it as I've been stuck on this now for a week. Since it worked fine before they "turned off GET for WSDL" i wasn't prepared to start working on this again …

    Re: username/password: that's a temporary debug user/password that only works right now and for nothing else. I requested it so I can use it for this type of queries.

     
  • Scott Nichol

    Scott Nichol - 2010-05-03

    >>>>
    So it at least seems that the SOAP request and response are going through without any errors.
    What I was a bit curious about is that they say "Access is done through https as it requiers username and password for verification". Am I right that this is a reason why I would use "setCredentials()"?
    <<<<
    I am confused by this as well.   HTTPS itself does not require authentication, but you can use authentication with it just like HTTP.  However, since they send a SOAP response to your SOAP request, it seems that whatever you are doing (calling setCredentials or not) is fine.  For a failure to authenticate at the HTTPS level, they would never read your SOAP request and thus not send a SOAP response.

     

Log in to post a comment.