XMLPort to Blob

jwilder
Member Posts: 263
I have found some strange behavior with XMLPorts and need help. I am trying to stream the xml port to a blob (instead of a file which is more normal).
The following code does this (TempBlob is Temp Table 99008535):
Customer.SETFILTER("No.",'100000');
IF Customer.FINDFIRST THEN BEGIN
TempBlob."Primay Key" := 1;
TempBlob.INSERT;
TempBlob.Blob.CREATEOUTSTREAM(Streamout);
XMLPORT.EXPORT(XMLPORT::WSTestCustomer,Streamout,Customer);
TempBlob.MODIFY;
TempBlob.Blob.EXPORT('c:\test1.xml',FALSE);
end;
This works fine. The XMLPort is streamed into a blob, then the blob is exported to a file. Now I wanted to to the same thing expect read the blob into a BigText variable. This code here doesn't really work:
Customer.SETFILTER("No.",'100000');
IF Customer.FINDFIRST THEN BEGIN
TempBlob."Primay Key" := 1;
TempBlob.INSERT;
TempBlob.Blob.CREATEOUTSTREAM(Streamout);
XMLPORT.EXPORT(XMLPORT::WSTestCustomer,Streamout,Customer);
TempBlob.MODIFY;
TempBlob.Blob.CREATEINSTREAM(StreamIn);
TestBigText.READ(StreamIn);
TestBigText.GETSUBTEXT(TestText,1);
MESSAGE(TestText);
END;
This message box displays P< not matter what customer filter I use. If someone can help me get this to work then I will have figured out a way to pass actual xml back through web services without use the msxmldom.
By the way the xmlport generates the following file (not that it should matter):
<?xml version="1.0" encoding="UTF-16" standalone="no" ?>
<MyXMLCustomers>
<MyXMLCustomer>
<No>100000</No>
<Name>DONNA MCNEIL</Name>
<City>PORTLAND</City>
</MyXMLCustomer>
</MyXMLCustomers>
The following code does this (TempBlob is Temp Table 99008535):
Customer.SETFILTER("No.",'100000');
IF Customer.FINDFIRST THEN BEGIN
TempBlob."Primay Key" := 1;
TempBlob.INSERT;
TempBlob.Blob.CREATEOUTSTREAM(Streamout);
XMLPORT.EXPORT(XMLPORT::WSTestCustomer,Streamout,Customer);
TempBlob.MODIFY;
TempBlob.Blob.EXPORT('c:\test1.xml',FALSE);
end;
This works fine. The XMLPort is streamed into a blob, then the blob is exported to a file. Now I wanted to to the same thing expect read the blob into a BigText variable. This code here doesn't really work:
Customer.SETFILTER("No.",'100000');
IF Customer.FINDFIRST THEN BEGIN
TempBlob."Primay Key" := 1;
TempBlob.INSERT;
TempBlob.Blob.CREATEOUTSTREAM(Streamout);
XMLPORT.EXPORT(XMLPORT::WSTestCustomer,Streamout,Customer);
TempBlob.MODIFY;
TempBlob.Blob.CREATEINSTREAM(StreamIn);
TestBigText.READ(StreamIn);
TestBigText.GETSUBTEXT(TestText,1);
MESSAGE(TestText);
END;
This message box displays P< not matter what customer filter I use. If someone can help me get this to work then I will have figured out a way to pass actual xml back through web services without use the msxmldom.
By the way the xmlport generates the following file (not that it should matter):
<?xml version="1.0" encoding="UTF-16" standalone="no" ?>
<MyXMLCustomers>
<MyXMLCustomer>
<No>100000</No>
<Name>DONNA MCNEIL</Name>
<City>PORTLAND</City>
</MyXMLCustomer>
</MyXMLCustomers>
Jason Wilder
jwilder@stonewallkitchen.com
jwilder@stonewallkitchen.com
0
Answers
-
Here is another way to demonstrate the problem I am having. Stream an xmlport to a blob (instead of streaming to a file like we normally do). You can then export the blob to a text file via blob.export (which totally works) but you cannot stream the blob to a bigtext variable. As soon as you turn the blob into a bigtext it only displays P<.Jason Wilder
jwilder@stonewallkitchen.com0 -
Try to use CALCFIELDS before streaming it into BigText. But it is just a tip...0
-
I somehow figured this. The xmlport encoding property was UFT-16. This encoding seems to create a weird character at the beginning of the file that was causing my problem (this character is not visible in an advanced text editor). As soon as I changed the encoding to UTF-8 (only other option in NAV) my problem went away!
I can now send actual xml back through my web service!
How do you mark something a ssolved?Jason Wilder
jwilder@stonewallkitchen.com0 -
By editing the first post and select the "Solved" flag in appropriate editbox...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