NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: osquiabro on September 30, 2015, 05:33:49 AM
-
is possible that return a image from webservice stored at blob?
-
yes - have a look at the xfiles docs if using xml on how to add a binary file to your xml structure.
-
do you try this?
the problem is that NetwebServiceMethod don't recognize a blob field and return this error:
Variable expected - C:\Apps\CatastroCasos\CatastroWeb10Test\CatastroWeb10037.clw:245,138
packet.append(all(' ',IndentLen) & '<'&p_web.Nocolon('DocumentContent',Net:SingleUnderscore+Net:NoSpaces)&'>' & p_web.AsciiToUtf(Cod:DocumentContent) & '</'&p_web.Nocolon('DocumentContent',Net:SingleUnderscore+Net:NoSpaces)&'><13,10>')
-
I asked Bruce about blob fields during a Nettalk webinar and he said that blob fields are not handled by the templates. However you can send and receive binary data as stringtheory fields. When sending a blob from a web service, create a stringtheory return field. In the service method embed, pass your blob data to the stringtheory object, then do a Base64 encode on the value. The client program will receive the string value in XML or JSON object in the page received from the web service. In the AssignField embed of the XML or JSON object intercept the field name of the stringtheory field. Place the value into a client side string theory object. Base64 decode the stringtheory value, then copy the value to the blob field on the client database.
I hope this helps.
Rob
-
I'm sending an XML structure with a base64 encoded file to a web service. I think returning an image as part of the response XML could be done in a similar way but I have not tried it. Some of the code below may help.
xml.SaveCurrentFieldToXML PROCEDURE (Long p_x,Long p_DimCounter,String p_name)
! Start of "Class Method - Data Section"
! [Priority 5000]
! End of "Class Method - Data Section"
CODE
! Start of "Class Method - Executable Code Section"
! [Priority 2500]
If p_x = 9
xml2.Append = 0
xml2._Indent = self._Indent
xml2.OmitXMLHeader = 1
xml2.DontSaveBlanks = 1
xml2.Save(QInvoice.File,'Files','File')
self._NoEncodeDecode = 1
self._sFieldNameLen[p_x] = 0
self.CurrentField &= xml2.xmlData
END
! Parent Call
PARENT.SaveCurrentFieldToXML (p_x,p_DimCounter,p_name)
! [Priority 7500]
If p_x = 9
xml._NoEncodeDecode = 0
END
xml2.SaveCurrentFieldToXML PROCEDURE (Long p_x,Long p_DimCounter,String p_name)
! Start of "Class Method - Data Section"
! [Priority 5000]
! End of "Class Method - Data Section"
CODE
! Start of "Class Method - Executable Code Section"
! [Priority 2500]
If p_name = 'FileName'
L:FileName = self.CurrentField
END
If p_name = 'EncodedFile'
If L:FileName = ''
Message('No filename')
ELSE
st.LoadFile(clip(Glo:DataPath) & Clip(L:FileName))
st.base64NoWrap = 1
st.Base64Encode()
self.CurrentField &= st.GetValuePtr()
END
END