Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsdl file fetch with NTLM? #4

Open
benyanke opened this issue Oct 2, 2017 · 6 comments · May be fixed by #11
Open

wsdl file fetch with NTLM? #4

benyanke opened this issue Oct 2, 2017 · 6 comments · May be fixed by #11

Comments

@benyanke
Copy link
Contributor

benyanke commented Oct 2, 2017

I have read PHP bugs (I wish I could find them again....) that even if the SOAP connection is using a given auth, the WSDL file can not be fetched using the same auth.

Currently, even with your library, I'm having to manually download my WSDL files from my Navision 2013 R2 instance, and point the SoapClient at the filesystem instead of the URL. Is there a workaround for this with your library?

@Morgon
Copy link

Morgon commented Nov 4, 2017

Came here looking for the same. Sadly it looks like rolling your own is the only way to do it at the moment. I found this, which seems promising.

@jasonhildebrand
Copy link

@benyanke: I'm having the same issue with NAV 2015. Could you post an example of how you are using local WDSL file?

@benyanke
Copy link
Contributor Author

benyanke commented Nov 6, 2017

In essence, I'm just manually storing them in my repository, but my soap client constructor is below. In short, $wsdl contains the filesystem path to the XML file I manually downloaded and stored, and then this getSoapClient function is used in place of the new SoapClient() throughout my code.

<?php
use \jamesiarmes\PhpNtlm\SoapClient;
[...]
class NavBaseModel {
[...]
    public static function getSoapclient(string $pagename) {
        $wsdl = base_path().
        "/resources/nav/wsdlfiles/".config('nav.soapconnection.pages.'.$pagename).
        ".xml";

        return new SoapClient(
            $wsdl,
            array(
                'user' => config('nav.soapconnection.username'),
                'password' => config('nav.soapconnection.password')
            )
        );
    }
[...]
}

@jasonhildebrand
Copy link

OK, that's what I was trying, but I kept getting PHP Fatal error: Uncaught SoapFault exception: [HTTP] Unauthorized when later trying to invoke a soap method.

I am having more success with https://github.com/matejsvajger/ntlm-soap-client, I'm able to make SOAP calls without needing local copies of WSDL files.

@benyanke
Copy link
Contributor Author

benyanke commented Nov 6, 2017

I will check that out. That package must properly fetch the WSDL files using NTLM auth.

@benyanke
Copy link
Contributor Author

Note: I was able to fetch my WSDL file using the following code. Have zero time to implement this in the package and turn this into a PR, but if someone else wants to, here it is:

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $wsdlFile);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
  curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true);
  curl_setopt($ch, CURLOPT_USERPWD, config('nav.soapconnection.username') . ":" . config('nav.soapconnection.password'));

  $wsdlFileContent = curl_exec($ch);
  curl_close($ch);

@das-peter das-peter linked a pull request Apr 29, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants