[solved] Problem setting up the webservice

lapelape Posts: 16Member
Hi there,
I have problem calling the webservice on NAV2009 R2.
I Installed the service on the same machine the sql server is installed.
I set up a WS in Form 810 and published it.
The service is running and I can open the service wsdl http://[servername]:7047/DynamicsNAV/WS/Services | http://[servername]:7047/DynamicsNAV/WS/[company]/Page/WSCustomer
I downloaded the xml and imported it in soapui.

When I submit the request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:cus="urn:microsoft-dynamics-schemas/page/WSCustomer">
<soapenv:Header/>
<soapenv:Body>
<cus:Read>
<cus:No>0000001</cus:No>
</cus:Read>
</soapenv:Body>
</soapenv:Envelope>

I get the result
#status# HTTP/1.1 401 Unauthorized.

I also set the Authorization to Basic entered a username / password of a user whitch is known in nav and has the role super.

Has anyone any idea?

Best Answers

  • lapelape Posts: 16
    edited 2019-04-23 Accepted Answer
    I changed the CunstomSerrings.config in the Service folder:
    from
    <add key="WebServicesUseNTLMAuthentication" value="false"></add>
    to
    <add key="WebServicesUseNTLMAuthentication" value="true"></add>
    I restarted the NAV Services (Business Webservice and Server)

    Then I did the same I described above
    ...
    http://[myserver]:7047/DynamicsNAV/WS/Page/WSCust
    Download the result as xml
    Changed the Company (ReplaceWithAPercentEncodedCompanyName)
    Create new soap in soapui, select the xml, ok
    create a new read request
    changed the customer no
    <wsc:No>?</wsc:No>
    -> <wsc:No>0000001</wsc:No>

    select Auth -> add new -> ntlm
    username
    password
    (domain)
    -> fire
    #status# HTTP/1.1 401 Unauthorized
    Server Microsoft-HTTPAPI/2.0
    Content-Length 0
    Date Thu, 18 Apr 2019 05:59:23 GMT
    WWW-Authenticate Negotiate
  • ftorneroftornero Posts: 241
    Accepted Answer
    Hello @lape,

    Well I don't know what to say, after the change for the "WebServicesUseNTLMAuthentication" value, it works for me.

    Maybe you must check if you have more the one service runnig, because after the change the error message if there is a Authetication problem must be:

    WWW-Authenticate NTLM

    No

    WWW-Authenticate Negotiate.

    Regards

Answers

  • ftorneroftornero Posts: 241Member
    SoapUI does not deal well with the Authentication used by NAV.

    You can try this Powershell script to test the connection:
    $username = "user"
    $password = "password*"
    
    $URI = "your_URL"
    
    $cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
    
    $WSProxy = New-WebServiceProxy -Uri $URI -Credential $cred
    
    $WSProxy.Read('0000001')
    

    Regards
  • lapelape Posts: 16Member
    this works fine but why does soapui fail?
  • ftorneroftornero Posts: 241Member
    Hello @lape,

    How I told before, SoapUI does not work with the Authentication that use NAV, or at least I not been able to do.

    Regards.
  • DuikmeesterDuikmeester Hoorn, The NetherlandsPosts: 296Member
    edited 2019-04-17
    It does if you enable NTLM authentication in the services configuration.
  • ftorneroftornero Posts: 241Member
    Hello @Duikmeester ,

    Thank you, it works, the true is that I don't use SoapUI much because I test WS with Powershell or XMLSpy.

    Regards.
  • lapelape Posts: 16Member
    I Configured the webservice that ntlm is used unfortunately it doesnt work.
  • ftorneroftornero Posts: 241Member
    Hello @lape,

    Could you elaborate ?

    Is the error still the same ? 401 Unauthorized.

    Regards
  • lapelape Posts: 16Member
    edited 2019-04-23 Accepted Answer
    I changed the CunstomSerrings.config in the Service folder:
    from
    <add key="WebServicesUseNTLMAuthentication" value="false"></add>
    to
    <add key="WebServicesUseNTLMAuthentication" value="true"></add>
    I restarted the NAV Services (Business Webservice and Server)

    Then I did the same I described above
    ...
    http://[myserver]:7047/DynamicsNAV/WS/Page/WSCust
    Download the result as xml
    Changed the Company (ReplaceWithAPercentEncodedCompanyName)
    Create new soap in soapui, select the xml, ok
    create a new read request
    changed the customer no
    <wsc:No>?</wsc:No>
    -> <wsc:No>0000001</wsc:No>

    select Auth -> add new -> ntlm
    username
    password
    (domain)
    -> fire
    #status# HTTP/1.1 401 Unauthorized
    Server Microsoft-HTTPAPI/2.0
    Content-Length 0
    Date Thu, 18 Apr 2019 05:59:23 GMT
    WWW-Authenticate Negotiate
  • ftorneroftornero Posts: 241Member
    Hello @lape

  • ftorneroftornero Posts: 241Member
    Accepted Answer
    Hello @lape,

    Well I don't know what to say, after the change for the "WebServicesUseNTLMAuthentication" value, it works for me.

    Maybe you must check if you have more the one service runnig, because after the change the error message if there is a Authetication problem must be:

    WWW-Authenticate NTLM

    No

    WWW-Authenticate Negotiate.

    Regards
  • lapelape Posts: 16Member
    That was a helpful hint!
    I can't see a second service but after changeing the port in the config the authentication works well.
    Now there is another Problem:
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
       <s:Body>
          <s:Fault>
             <faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:System.Net.WebException</faultcode>
             <faultstring xml:lang="de-DE">Soap message is invalid!</faultstring>
             <detail>
                <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Soap message is invalid!</string>
             </detail>
          </s:Fault>
       </s:Body>
    </s:Envelope>
    
    but for this there seems to be a hotfix (no longer available >:))
  • lapelape Posts: 16Member
    edited 2019-04-23
    Workaround for "Soap message is invalid!" without installing the hotfix:
    1. Remove all line breaks and unneccessary spaces between ><
    2. Change the namespace 'soapenv' to 'soap'

    thanks @goback (@mibuso)
  • ftorneroftornero Posts: 241Member
    Hello @lape,

    If with the Plowershell script the WS works, that means that the problem must be with the XML that you are sending..

    Try this, in this line change the cus urn to all lowercase
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:cus="urn:microsoft-dynamics-schemas/page/WSCustomer">
    

    Like this:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:cus="urn:microsoft-dynamics-schemas/page/wscustomer">
    

    That it is how the SoapUI version I use do it.

    Regards.
Sign In or Register to comment.