Options

XMLPort to Blob

jwilderjwilder Member Posts: 263
edited 2009-04-04 in NAV Three Tier
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>

Answers

  • Options
    jwilderjwilder Member Posts: 263
    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<.
  • Options
    kinekine Member Posts: 12,562
    Try to use CALCFIELDS before streaming it into BigText. But it is just a tip...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jwilderjwilder Member Posts: 263
    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?
  • Options
    kinekine Member Posts: 12,562
    By editing the first post and select the "Solved" flag in appropriate editbox...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.