Creating an outsream and in stream of XML data..

prateekarya2011
Member Posts: 40
Hii all experts I am facing an issue and need your valuable suggestions,
Problem -->
1)NAV System XML File/data outstream
> 2)System 2(Reads the data processes it)
| |
4) <--NAV reads the data and stores it <
3)XML Stream data back to nav<
Most of the experts must have done this.. just seeking the idea... is it feasible if yes plz give an example of how to do it...? =P~
Thanks In Advance
Problem -->
1)NAV System XML File/data outstream
> 2)System 2(Reads the data processes it)
| |
4) <--NAV reads the data and stores it <
3)XML Stream data back to nav<
Most of the experts must have done this.. just seeking the idea... is it feasible if yes plz give an example of how to do it...? =P~
Thanks In Advance
0
Comments
-
You mean something like "Calling webservice from NAV"? ;-)0
-
Thanks Kine for the replies.. =D> and thanks for giving your valuable time to read and reply on my doubt..
The thing is that client doesnot wants to consume any web service.. what it needs is stream of data in XML kind of file.
I had given this Web service kind of solution but they are not ready to consume any kind of web service they simply want XML data stream into their system. :roll:
Any solution to create a stream of xml data that should go into there system?? or any other opinion please share...
Thanks in advance0 -
Hi
Try this
CREATE XML in NAV:
Variables
Name DataType Subtype Length
InText InStream
OutText OutStream
LONGTEXT BigText
TempBLOB Record TempBlob
XMLHttp Automation 'Microsoft WinHTTP Services, version 5.1'.WinHttpRequestCLEAR(LONGTEXT); LONGTEXT.ADDTEXT('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" '); LONGTEXT.ADDTEXT('<soapenv:Header/><soapenv:Body>'); .... You creates yous XML structure
Now, you can conver the LONGTEXT variable info into an INSTREAM.TempBLOB.INIT; TempBLOB.Blob.CREATEOUTSTREAM(OutText); LONGTEXT.WRITE(OutText); TempBLOB.CALCFIELDS(Blob); TempBLOB.Blob.CREATEINSTREAM(InText);
Now you have your XML data in InText, so you can send it to a WS or save in a folder.XMLHttp.Open('POST','http://WebServicePAth/WebServiceFunction'); XMLHttp.SetRequestHeader('Content-Type','text/xml; charset=utf-8'); XMLHttp.SetRequestHeader('SOAPAction', 'SendXMLFile'); XMLHttp.Send(InText);
READ XML in NAV:
You need a function who receives a BIGTEXT parameter
Variables
Name DataType Subtype Length
XMLDocument Automation 'Microsoft XML, v6.0'.DOMDocument60
ReadStream InStream
WriteStream OutStream
TempBlob Record TempBlobReceiveData(IncomeText : BigText) CLEAR(XMLDocument); CREATE(XMLDocument); TempBlob.INIT; TempBlob.Blob.CREATEOUTSTREAM(WriteStream); IncomeText.WRITE(WriteStream); TempBlob.CALCFIELDS(Blob); TempBlob.Blob.CREATEINSTREAM(ReadStream); XMLDocument.load(ReadStream); XMLDocument.save('C:\xml.xml');
With this code, you can save the info you receive into a XML file. Now you can create some code or XMLPort to conver this XML and write this info in tables.
I hope this could be a start guide to do it.
Regards0 -
hiii Saalek.. Thanks for alloting your valuable time to my post & thanks a lot for eplaining the example so clearly...
I am seeking one more favor from you actually am working in 2031R2
system is generating following error while running the CU
Streams cannot be used with client-side invoked automation objects.
Any idea how can we deal with this???
Thanks in advance to Saalek and all other experts0 -
Hi
I think this will be solved when you crear the automation instance.
CREATE(XMLDOCUMENT,false,TRUE);
Regards0 -
Hi
I think this will be solved when you crear the automation instance.
CREATE(XMLDOCUMENT,false,TRUE);
Regards
Hii Saalek the code create(XMLDocument,FALSE,TRUE) i had already done that but system is giving error at
Xmlhttp.Send(Intext);
sorry but this could not be resolved by modifying create function as i have already done that...
Ny other suggestion.....
Thanks
Saalek0 -
Hi
In my example. I sent you one Web Servce call example.
The URL isn't real. If you want to save the XML and not to send it, Use a XMLDOM.Document and save it in you local drive.XMLHttp.Open('POST','http://WebServicePAth/WebServiceFunction'); XMLHttp.SetRequestHeader('Content-Type','text/xml; charset=utf-8'); XMLHttp.SetRequestHeader('SOAPAction', 'SendXMLFile'); XMLHttp.Send(InText);
You can replace this text withXMLDocument.load(InText); XMLDocument.save('C:\xml.xml');
Regards0 -
hii Saalek thanks a lot for all your time and posts, actually issue isn't about dummy web address rather issue in NAV 13 R2
Whenever we are creating any automation variable for Example
CREATE(XMLDomDoc,FALSE,TRUE);
then we call the function
XMLDom.save(StreamOutObj); system generates the error..
Streams cannot be used with client-side invoked automation objects.
this happens with every automation which tries to save or load file.
Thanks for all ur help... =D>0 -
Just want to add: calling WS through SOAP is just "Exchange of XML streams...". It means, calling webservice is just "streaming XML data between two systems". It have just specific format of the envelope... ;-)0
-
Hello guys,
I have the same problem, I need to connect at webservice of onther company, so I must use this sentence above!!?0 -
No, why? If you are connecting to webservice, you do not need any sentence like this. Just generate correct SOAP with correct data and send them. Than receive the answer and process them. You do not need to argue with someone...0
-
Hello guys,
I have to comunicate with another WS program, so I have used the example above, that for me is a good example but I can't to inizialize the Automation
object :
CREATE(XMLHttp,FALSE,TRUE);
every time it returned FALSE, darm it !!!
somebody may be help me!??
this is my code :
CLEAR(LONGTEXT);
LONGTEXT.ADDTEXT('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/wsdl/soap/"');
LONGTEXT.ADDTEXT('<soapenv:Header/><soapenv:Body>');
LONGTEXT.ADDTEXT('<?xml version="1.0" encoding="UTF-8/"?>');
LONGTEXT.ADDTEXT('<sgate:PresaInCaricoLotto xmlns:sgate="http://www.sgate.ancitel.it/xsd/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="xxxxxxxxxxxxxxxxxxxxxx/xsd/ 01_SGATEGAS_XSD_DISTRIBUTORI_v1.17.xsd">');
LONGTEXT.ADDTEXT(' <sgate:tipoRichiestaPresaInCaricoLotto>');
LONGTEXT.ADDTEXT(' <sgate:tipoMittente>');
LONGTEXT.ADDTEXT(' <sgate:Login></sgate:Login>');
LONGTEXT.ADDTEXT(' <sgate:Password></sgate:Password>');
LONGTEXT.ADDTEXT(' </sgate:tipoMittente>');
LONGTEXT.ADDTEXT(' <sgate:idUltimoLottoRicevutoCorretta></sgate:idUltimoLottoRicevutoCorretta>');
LONGTEXT.ADDTEXT(' <sgate:numeroMessaggi>2</sgate:numeroMessaggi>');
LONGTEXT.ADDTEXT('</sgate:PresaInCaricoLotto>');
TempBLOB.INIT;
TempBLOB.Blob.CREATEOUTSTREAM(OutText);
LONGTEXT.WRITE(OutText);
TempBLOB.CALCFIELDS(Blob);
TempBLOB.Blob.CREATEINSTREAM(InText);
ReturnValue := CREATE(XMLHttp,TRUE,TRUE);
IF ReturnValue = TRUE THEN BEGIN
XMLHttp.Open('POST','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo',FALSE);
XMLHttp.SetRequestHeader('Content-Type','text/xml; charset=utf-8');
XMLHttp.SetRequestHeader('SOAPAction', 'SendXMLFile');
XMLHttp.Send(InText);
END;
IF ISCLEAR(XMLDocument) THEN BEGIN
IF CREATE(XMLDocument,FALSE,TRUE) = TRUE THEN BEGIN
CLEAR(XMLDocument);
CREATE(XMLDocument,FALSE,TRUE);
TempBLOB.INIT;
TempBLOB.Blob.CREATEOUTSTREAM(WriteStream);
IncomeText.WRITE(WriteStream);
TempBLOB.CALCFIELDS(Blob);
TempBLOB.Blob.CREATEINSTREAM(ReadStream);
XMLDocument.load(ReadStream);
XMLDocument.save('C:\xml.xml');
END;
END;
thanks :?0 -
Hi prateekarya2011,
Have you found a solution for the error?. Please guide me to solve the same error in my following code. I am getting the error while trying to Load the InStream.
//setup the temporary table so that we can handle the XML without saving it to disk first
//create a couple of streams to transfer the data in and out of the BLOB field
CLEAR(TempTable);
TempTable.Blob.CREATEINSTREAM(InStr);
TempTable.Blob.CREATEOUTSTREAM(OutStr);
//the request XMLport fills the BLOB with the XML message
CLEAR(XP1);
XP1.SETDESTINATION(OutStr);
XP1.EXPORT;
//load the message into the XML automation variable
IF ISCLEAR(XMLDoc) THEN
CREATE(XMLDoc,FALSE,TRUE);
XMLDoc.load(InStr);
//this is for diagnostics only, so you can see what the XMLport actually produced
XMLDoc.save('C:\Temp\XMLRequest.txt');
//create the HTTP connector
IF ISCLEAR(XMLHttpConn) THEN
CREATE(XMLHttpConn,FALSE,TRUE);0 -
Hello, guys
I have found this documentazion in internet :
Written by Vjekoslav Babic
http://NavigateIntoSuccess.com/
vjekoslav.babic@fortempo.net
This code is provided with no warranties of any kind, and you are using it entirely at your own responsibility.
You are free to use and modify this codeunit as you like and with no limitations, provided that:
1) You do not delete this Documentation trigger and do not put any other comments above this.
2) You visit my blog at http://NavigateIntoSuccess.com/ and leave a comment saying that this helped.
And of course - I leave the enforcement of these requirements entirely up to you :-)
It's very gret to read data from a page of a NAV2013 from other NAV2013 by a codeunit. Now I have neceserity to made a comunication from NAV2013 to NAV2013 trought the codeunits.
Somebody of you have just modify the code description before?0 -
Hi
Try this
CREATE XML in NAV:
Variables
Name DataType Subtype Length
InText InStream
OutText OutStream
LONGTEXT BigText
TempBLOB Record TempBlob
XMLHttp Automation 'Microsoft WinHTTP Services, version 5.1'.WinHttpRequestCLEAR(LONGTEXT); LONGTEXT.ADDTEXT('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" '); LONGTEXT.ADDTEXT('<soapenv:Header/><soapenv:Body>'); .... You creates yous XML structure
Now, you can conver the LONGTEXT variable info into an INSTREAM.TempBLOB.INIT; TempBLOB.Blob.CREATEOUTSTREAM(OutText); LONGTEXT.WRITE(OutText); TempBLOB.CALCFIELDS(Blob); TempBLOB.Blob.CREATEINSTREAM(InText);
Now you have your XML data in InText, so you can send it to a WS or save in a folder.XMLHttp.Open('POST','http://WebServicePAth/WebServiceFunction'); XMLHttp.SetRequestHeader('Content-Type','text/xml; charset=utf-8'); XMLHttp.SetRequestHeader('SOAPAction', 'SendXMLFile'); XMLHttp.Send(InText);
READ XML in NAV:
You need a function who receives a BIGTEXT parameter
Variables
Name DataType Subtype Length
XMLDocument Automation 'Microsoft XML, v6.0'.DOMDocument60
ReadStream InStream
WriteStream OutStream
TempBlob Record TempBlobReceiveData(IncomeText : BigText) CLEAR(XMLDocument); CREATE(XMLDocument); TempBlob.INIT; TempBlob.Blob.CREATEOUTSTREAM(WriteStream); IncomeText.WRITE(WriteStream); TempBlob.CALCFIELDS(Blob); TempBlob.Blob.CREATEINSTREAM(ReadStream); XMLDocument.load(ReadStream); XMLDocument.save('C:\xml.xml');
With this code, you can save the info you receive into a XML file. Now you can create some code or XMLPort to conver this XML and write this info in tables.
I hope this could be a start guide to do it.
Regards
Hello,
When I try to use this code and send the http request, it gives me the following error: Unable to use streams with ActiveX objects called on the client side.
Can you help me? I did everything you listed to send the http request:
TempBlob.INIT;
TempBlob.Blob.CREATEOUTSTREAM(OutStream);
JsonBigText.WRITE(OutStream);
TempBlob.CALCFIELDS(Blob);
TempBlob.Blob.CREATEINSTREAM(InStream);
CREATE(Http, FALSE, TRUE);
Http.Open('POST', '[my endpoint]');
Http.SetRequestHeader('Content-Type', 'application/json');
Http.SetRequestHeader('Authorization', '[my auth]');
Http.SetRequestHeader('Accept', 'application/json');
Http.Send(InStream);
Thanks0 -
Do not use variables declared with 'Automation' type anymore.This type can be used upto BC14, but only CAL and on client (RTC 32bit .exe) side. While all other code runs server side. Absolute legacy, and as good as unusable now. Search for xml creation with 'DotNet' type. This replaced 'Automation' type a long time ago. There are plenty examples to be found here.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions