Options

Communicating with Web Service

AdministratorAdministrator Member, Moderator, Administrator Posts: 2,496
edited 2011-06-20 in Download section
Communicating with Web Service
This small example shows how to communicate with a webservice from Navision.
Both SOAP and HTTP protocol comunication is shown.

You must handle exceptions/errors yourself. The examples are just meant for you to learn from.

I also included source code for a very simple web service written in C# on which the Navision code is based.

http://www.mibuso.com/dlinfo.asp?FileID=539

Discuss this download here.

Comments

  • Options
    PrebenRasmussenPrebenRasmussen Member Posts: 137
    From the auther:

    The supplied example web service is created in Visual Studio 2003.

    If you need assistance, don't hesitate to use the forum.

    Note: Setting the correct namespace from Navision can be difficult. Make sure you check the specifications of the WSDL thoroughly.
  • Options
    DakkonDakkon Member Posts: 192
    A most excellent post. I've often wondered how to do this from Navision, although so far haven't had a pressing reason to sit down and try. This will save me many hours when I finally need to call some web services:)
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • Options
    DevInChiDevInChi Member Posts: 5
    Thanks for this post it has been very helpful. I am having one issue though. I cannot get the SOAPwithParameter function to work. The web service is being called, but the parameter is coming over as 0. I cannot see what I'm doing wrong. Any suggestions on where to look?
    ](*,)
  • Options
    RikaRika Member Posts: 1
    Hey everyone, i'm having sort of a problem with this "Communicating with Web Service".

    I've followed all the steps in the code, changed a little bit to my needs and yet he returns with an error i cannot identify.

    <?xml version="1.0" encoding="utf-8" ?>
    - <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    - <soap:Body>
    - <soap:Fault>
    <faultcode>soap:VersionMismatch</faultcode>
    <faultstring>Possible SOAP version mismatch: Envelope namespace was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/.
    <detail />
    </soap:Fault>
    </soap:Body>
    </soap:Envelope>

    This is the error, hope u guys can help me out.

    Thanks

    Thanks to the author for this beautiful program ;)
  • Options
    KosheKoshe Member Posts: 37
    Hi all,
    i've been having difficulties using web services. I added to the given web service one more method, which takes string as a parameter and return string. The problem is that if I pass a value to the web service, only empty string is passed. With integers and decimals everything woks fine. Does anyone has any ideas how to solve this issue? :?:
  • Options
    LukLuk Member Posts: 4
    Hello everyone,

    I've downloaded the file and unzipped it. Then I've imported the .fob file into Navision, with success (I get 2 extra codeunits). From now, I'm not sure what to do? How can I see the webservice or is this something I have to create myself? Or is this download only a small piece of the solution?

    Please give me some feedback on this issue. Thank you!
    Best regards, Luk.
  • Options
    FrogFrog Member Posts: 6
    Hi all,

    I've downloaded this example and tryed to get the request from an official webservice form this site: http://www.webservicex.net/

    after chanching some details in the navision code although i get this error message:
    but i dont´t know the reason of this error?

    have someone an idea?
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    	<soap:Body>
    		<soap:Fault>
    			<faultcode>soap:Client</faultcode>
    			<faultstring>System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://www.webservicex.net/globalweather.asmx/GetWeather.
       at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
       at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
       at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)</faultstring>
    			<detail/>
    		</soap:Fault>
    	</soap:Body>
    </soap:Envelope>
    
    Thanks in advance
    Silvia
  • Options
    BGIBGI Member Posts: 176
    Hi all,
    been strugling with this for days now....
    it works because sample application sends this to the service and gets info, but i cannot get it translated into soap or html request...
    any ideas on how to proceed with this syntax?

    POST /CCMApi/AXL/V1/soapisapi.dll
    Host: x.x.x.x:80
    Accept: text/*
    Authorization: Basic xxxx
    Content-type: text/xml
    Content-length: 480

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    <SOAP-ENV:Body>
    <axl:getPhone xmlns:axl="http://www.cisco.com/AXL/1.0&quot; xsi:schemaLocation="http://www.cisco.com/AXL/1.0 http://gkar.cisco.com/schema/axlsoap.xsd" sequence="392">
    <phoneName>SEP0011924AADC0</phoneName>
    </axl:getPhone>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


    this should be the response...

    Received Packet len 65 (5320 remaining)
    HTTP/1.1 200 OK
    Content-Type: text/xml
    Content-Length: 5255

    Received Packet len 5255 (5255 remaining)
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/&quot; SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
    <SOAP-ENV:Body>
    <axl:getPhoneResponse xmlns:axl="http://www.cisco.com/AXL/API/1.0&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation="http://www.cisco.com/AXL/API/1.0 http://CMPUBSRV/CCMApi/AXL/V1/axlsoap.xsd" sequence="392">

    etc...
    Rgds
    Benny Giebens
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    This evening, there is a MSDN session about Web Services with NAV, at Microsoft's location in Diegem. See topic Belgian MSDN/TechNet Evenings on Dynamics NAV.

    Maybe you can attend?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    BGIBGI Member Posts: 176
    I'll be there....with some collegues...

    but in the mean time i was able to get the connection going...with the help of some other examples....


    CREATE(locautXmlDoc);
    locautXmlDoc.async := FALSE;
    locautXmlDoc.load('C:\Input.xml');
    CREATE(locautXmlHttp);
    locautXmlHttp.open('POST','HTTP://10.0.0.245/CCMApi/AXL/V1/soapisapi.dll',0,'user','pasword');
    locautXmlHttp.setRequestHeader('Host','10.0.0.245:80');
    locautXmlHttp.setRequestHeader('Accept','text/*');
    locautXmlHttp.setRequestHeader('Content-type','text/xml');
    locautXmlHttp.setRequestHeader('Content-length','480');

    locautXmlHttp.send(locautXmlDoc);

    locautXmlDoc.load(locautXmlHttp.responseXML);
    locautXmlDoc.save('C:\temp.xml');


    And it works...
    Now the hard part...getting some functionality out of this...but the start is there..
    Rgds
    Benny Giebens
  • Options
    amphysvenaamphysvena Member Posts: 113
    Hi,
    Great sample. I wonder if I can use complex data type in the XmlHttp. For example, the webservice using binary or records as the parameter. Can it be called by XmlHttp?
    Thanks
  • Options
    GRIZZLYGRIZZLY Member Posts: 127
    My experience in implementing webservice in NAV for server-side and client-side at http://x-dynamics.blogspot.com
    Any comments are welcome!
    Sincerely yours, GRIZZLY
    Follow my blog at http://x-dynamics.blogspot.com
Sign In or Register to comment.