Options

consuming NAV2009 Webservice via PHP

roederbroederb Member Posts: 6
edited 2015-06-22 in NAV Three Tier
Hello,

can't consume the NAV-Webservices via PHP nor get the service in soapui running, respectively proper results. adjustet the CustomSettings.config for the webservice configuration "WebServicesUseNTLMAuthentication" to true. so i can access the service via soapui but always get the result:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
<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>

can anybody provide an example how to consume a webservice from within PHP?

Thanks in advance your help is highly appreciated

Kind regards
Bernd

Comments

  • Options
    kinekine Member Posts: 12,562
    I recommend to use SOAPUI application to look how the request looks and how the answer looks like. It could help you to correctly create the XML request message etc..
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    ara3nara3n Member Posts: 9,256
    SOUPUI still can't authenicate. But you still can use it see how the xml file should be created.

    Open the WSDL in internet explorer and save it as a file and then load that in SOAPUI.

    This way you can see the XML structure you need to create.
    The only solution I have is to use webproxy.

    http://mibuso.com/blogs/ara3n/2009/05/0 ... b-service/
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    roederbroederb Member Posts: 6
    Hi ara,

    thanks for your advice. I found that threat before. i actually managed to authenticate with soapui - at least i think. i could load the definition into soapui and could open the wsdl. but the response i got was kind of soap message invalid :-(

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    <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>

    Read some posts from Freddy telling he's providing some examples but couldn't find anything. nay ideas besides the proxy?

    Thanks in advance
    Bernd
  • Options
    ara3nara3n Member Posts: 9,256
    Is your php running in windows or linux?

    If it's windows. You can use COM component (MSXMLDOM) and that works.


    Here is example on how to use

    http://mibuso.com/blogs/ara3n/2009/01/2 ... companies/
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Something like this? http://www.mehtanirav.com/2009/01/28/ws ... -wsdl-file

    I think you can find many similar tools googling PHP and WSDL.
  • Options
    ara3nara3n Member Posts: 9,256
    Freddy has posted the blog on how to connect from PHP to NAV.


    http://blogs.msdn.com/freddyk/archive/2 ... m-php.aspx

    =D> =D>
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    Yep - I am actually running through all the various platforms / programming languages I can think of (get access to) and make the very same sample on how to connect.

    At this time I have covered PHP, Java, Javascript, C# (both with .net 2.0 and 3.5 = Web Reference and Service Reference), Visual Basic (with the same) and right now I am working on a NAV 2009 SP1 implementation of the scenario.

    We can't hold peoples creativity back just because it is hard to get started...

    :)

    /Freddy
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • Options
    devnarendevnaren Member Posts: 1
    Hello Guys,

    Could you please suggest if somebody was able to consume the webservices in SOAP Clients like SOAP-UI .. i am facing the same issue as posted in this thread and wondering how to solve this.
    I am using NTLM authentication for these webservice invoke.

    Thanks,
    Naren
  • Options
    TimSimmondsTimSimmonds Member Posts: 47
    Hi,

    We'd also be interested in any final solution to this.

    We're trying to consume Nav webservices with Adobe Flex and so far are seeing a simliar error message: "SOAP message is invalid". Working it through SOAPUI, we can see in the log a mention of an authentication problem, even though SOAPUI allows you to enter credentials against it's tests.

    We're using the nav services set to NTML authentication, but are begining to think we need some sort of web service proxy. However, all this web stuff is new to us so any help would be appreciated.

    Cheers...
  • Options
    Simon79Simon79 Member Posts: 2
    We had similar issues and finally seem to have traced it to having whitespace between the opening soap body and message body.

    for example this works:

    <soap:Body><InboundMessage>

    while putting any whitespace or newlines between them results in the "Soap message is invalid!" response from the web service.

    for example this results in the error

    <soap:Body> <InboundMessage>

    Whitespacing\newslines in the rest of the SOAP message seem to make no difference, just on this line.

    We are using soap ui(http://sourceforge.net/projects/soapui/ ... oapui/4.0/) for making the web service calls and burp proxy (http://portswigger.net/burp/proxy.html) for the NTLM authentication.

    Can anybody confirm this? And can anyone suggest why this might be the case? I can consistently make successful calls without the whitespace and it will succeed, then add whitespace and it fails.... very straing.
  • Options
    TimSimmondsTimSimmonds Member Posts: 47
    Simon79 wrote:
    Can anybody confirm this? And can anyone suggest why this might be the case? I can consistently make successful calls without the whitespace and it will succeed, then add whitespace and it fails.... very straing.

    Hi,

    Yes we eventually came to the same conclusion. There is a hotfix available in build 32198

    https://mbs2.microsoft.com/Knowledgebas ... US;2510959

    I think Freddy's examples stringed the soap requests for his examples into one line hence he didn't suffer the same problem.

    For our own problem connecting with Adobe's flex we also had to have a windows service program to host the crossdomain.xml policy file that is required. The file is hosted on the same port as the webservice.

    Cheers, Tim
  • Options
    Simon79Simon79 Member Posts: 2
    Thanks for the confirmation Tim; we found the same hotfix after diagnosing the issue and it seems to have fixed it for us too.
  • Options
    gobackgoback Member Posts: 2
    I finally got SOAPUI to post a request (without installing the hotfix)
    1. Remove all line breaks and unneccessary spaces between ><
    2. Change the namespace 'soapenv' to 'soap'

    Authenticating through NTLM only works when using username, password and domain fields
    (by that I mean not using methods like username@domain or domain\username and leaving the domain empty)
  • Options
    Remco_ReinkingRemco_Reinking Member Posts: 74
    A little late, but because it took me some time to find out, my two cents to this problem:

    Another way to do so is to let SOAPUI remove the whitespaces:
    There is a requestproperty called "Strip Whitespaces", this one should be set to True.
  • Options
    ashishmlsashishmls Member Posts: 2
    how to call or consume this web service from android
    http://username:password@XX.XXX.XX.XXX:7047/DynamicsNAV/WS/androidservice/Page/GetStoredata?wsdl

    any help would be appreciated.
Sign In or Register to comment.