We need to compress (or rather uncompress) some data we send to a pda client using a webservice.
Below I have a simple concept that will work if consumed by a regular .net app.
Unfortuantly, as the compact framework doesn't have the IO.Compression classes we can't see how this is possible without writing our own compression algorithms (as you'd don't have the ability to uncompress at the pda client end).
We have to use .net 2 only.
Dim c As New TestClass
c.Prop1 = "Test"
c.Prop2 = 1234
Dim XmlMemStream As New IO.MemoryStream
Dim mySerilizedObj As Xml.Serialization.XmlSerializer = New Xml.Serialization.XmlSerializer(GetType(TestClass))
mySerilizedObj.Serialize(XmlMemStream, c)
Dim gz As New IO.Compression.GZipStream(XmlMemStream, IO.Compression.CompressionMode.Compress, False)
This needs to be done at application level and not Server Level (HTTP compression).
Thanks
You could try using SharpZipLib on the client, I have used it successfully on Compact Framework.
Related
I'm trying to send a large (~3 MB array of vector data from my native c++ host to its embedded dart VM using the async (Send/ReceivePort) pattern described in https://www.dartlang.org/articles/native-extensions-for-standalone-dart-vm/
My goal is to transfer a native c++ vector of Float32x4 to a typed dart Float32x4List object in one go.
All is well and jolly when I try and send integer arrays, and i was able to run the example in the tutorial, but when i try to construct a native Dart_CObject as in:
Dart_CObject obj;
obj.type = Dart_CObject_kTypedData;
obj.value.as_typed_data.type = Dart_TypedData_kFloat32x4;
obj.value.as_typed_data.values = &myData;
obj.value.as_typed_data.length = myDataLength;
Dart_PostCObject(reply_port_id, &obj);
I get:
vm/dart_api_message.cc:1105: error: unimplemented code
Since it seems that currently only Dart_TypedData_kUInt8 and Dart_TypedData_kInt8 appear to be ready for serialisation.
Is there a work-around for this? i.e. is there a way to push my native data to the dart VM as a uint8 blob and re-interpreting that buffer in dart as a Float32x4List?
You can send the data to Dart as an Uint8List and use the Float32x4List.view constructor to re-interpret the data as an Float32x4List. E.g.
Uint8List data = ...
Float32x4List view = new Float32x4List.view(data.buffer)
...
Is it possible to connect to a web service (for example send a HTTP Request) via VBA in Microsoft Access?
For example, the user clicks a button on a form, then a HTTP Request is sent to a web service that responds with OK.
Has anyone done this before?
Note: VBA, not VB.NET.
This is code I've used quite successfully with Access 2003. It's from the interwebs, copied and re-copied ages ago. It creates a XMLHttpRequest Object, sends an HTTP GET request, and returns the results as a string.
Public Function http_Resp(ByVal sReq As String) As String
Dim byteData() As Byte
Dim XMLHTTP As Object
Set XMLHTTP = CreateObject("MSXML2.XMLHTTP")
XMLHTTP.Open "GET", sReq, False
XMLHTTP.send
byteData = XMLHTTP.responseBody
Set XMLHTTP = Nothing
http_Resp = StrConv(byteData, vbUnicode)
End Function
sReq is the URL; the function returns the response. You may need to make sure ActiveX Data Objects are enabled under your References (in the VBA editor, go to Tools > References).
This is the code , which I used. You need to first reference Microsoft XML V6 for this code to work.
Public Sub GetPerson()
'For API
Dim reader As New XMLHTTP60
reader.Open "GET", "www.exmple.com/users/5428a72c86abcdee98b7e359", False
reader.setRequestHeader "Accept", "application/json"
reader.send
Do Until reader.ReadyState = 4
DoEvents
Loop
If reader.Status = 200 Then
Msgbox (reader.responseText)
Else
MsgBox "Unable to import data."
End If
End Sub
I have used the "Microsoft Office 2003 Web Services Toolkit 2.01" toolkit (available here) on a few projects. It worked pretty well for me, although I also wrote the web services it was talking to, so I had the luxury of being able to fiddle with both ends of the process when getting it to actually work. :)
In fact, I just upgraded one of those apps from Access_2003 to Access_2010 and the SOAP client part of the app continued to work without modification. However, I did encounter one wrinkle during pre-deployment testing:
My app would not compile on a 64-bit machine running 32-bit Office_2010 because it did not like the early binding of the SoapClient30 object. When I switched to using late binding for that object the code would compile, but it did not work. So, for that particular app I had to add a restriction that 64-bit machines needed to be running 64-bit Office.
Also, be aware that Microsoft's official position is that "All SOAP Toolkits have been replaced by the Microsoft .NET Framework." (ref. here).
I need to create a simple web service (being the "server"). The goal is to provide some data I do read in an Qt / C++ application as JSON data. Basically a JavaScript application in the browser shall read its data from the Qt app. It is usually a single user scenario, so the user runs a Google Maps application in her browser, while additional data come from the Qt application.
So far I have found these libs:
Qxt: http://libqxt.bitbucket.org/doc/0.6/index.html but being a newbie on C++/Qt I miss some examples. Added: I have found one example here
gSoap: http://www.cs.fsu.edu/~engelen/soap.html has more examples and documentation and also seems to support JSON
KD SOAP: http://www.kdab.com/kdab-products/kd-soap/ with no example as far as I can tell, docu is here
Qt features itself, but it is more about acting as a client: http://qt-project.org/videos/watch/qt-networking-web-services
Checking SO gives me basically links to the above libs
webservice with Qt with an example I do not really get.
How to Create a webservice by Qt
So basically I do have the following questions:
Which lib would you use? I want to keep it as simple as possible and would need an example.
Is there another (easy!) way to provide the JSON data to the JavaScript Web page besides the WebService?
-- Edit, remarks: ---
Needs to be application intrinsic. No web server can be installed, no extra run time can be used. The user just runs the app. Maybe the Qt WebKit could be an approach....
-- Edit 2 --
Currently checking the tiny web servers as of SO " Qt HTTP Server? "
As of my tests, currently I am using QtWebApp: http://stefanfrings.de/qtwebapp/index-en.html This is one of the answers of Edit 2 ( Qt HTTP Server? )
Stefan's small WebServer has some well documented code, is written in "Qt C++" and easy to use, especially if you have worked with servlets already. Since it can be easily integrated in my Qt project, I'll end up with an internal WebServer.
Some demo code from my JSON tests, showing that generating the JSON content is basically creating a QString.
void WebServiceController::service(HttpRequest& request, HttpResponse& response) {
// set some headers
response.setHeader("Content-Type", "application/json; charset=ISO-8859-1");
response.setCookie(HttpCookie("wsTest","CreateDummyPerson",600));
QString dp = WebServiceController::getDummyPerson();
QByteArray ba = dp.toLocal8Bit();
const char *baChar = ba.data();
response.write(ba);
}
If someone has easy examples with other libs to share, please let me know.
QByteArray ba = dp.toLocal8Bit();
const char *baChar = ba.data();
You don't need to convert the QByteArray to char array. Response.write() can also be called with a QByteArray.
By the way: qPrintable(dp) is a shortcut to convert from QString to char array.
i've got a webservice that is running on my local iis. Now i am trying to consume this webservice from a windows application.
I've added loggin in the web service that i am sure it is actually returning the data and it is.
But when i try and retreive it from my application it returns an empty datatable.
Any suggestions It actually breaks at where you get the datarow sins there are no data in the dattaable.?
PayM8Service payM8Service = new PayM8Service();
localhost.PayM8DataSet.PayM8DetailsGetDataTable payM8DetailsGetDataTable = payM8Service.GetPayM8Details(999999999, "631023012");
localhost.PayM8DataSet.PayM8DetailsGetRow row = (localhost.PayM8DataSet.PayM8DetailsGetRow)payM8DetailsGetDataTable.Rows[0];
decimal asd = row.Arrears;
decimal asda = row.Balance;
The DataTable, DataRow, DataView, and DataViewManager objects cannot be serialized and cannot be returned from an XML Web service. To return less than a complete DataSet, you must copy the data that you want to return to a new DataSet.
http://support.microsoft.com/kb/306134
I am trying to sent a byte array from my Blackberry application to a .NET webservice (asmx).
I am using the Sun Java Wireless Toolkit (WTK) 2.5.2 to generate the webservice stubs to use within the Blackberry solution. The WTK project settings are producing the stubs using the JSR 172 specification.
I have created the Webservice using .NET 2005, using the following method:
[WebMethod]
public string UploadImage(byte[] Data, string Name)
{
//do stuff
}
I generate the stubs from the WSDL of this webservice but I am receiving: "error: Found unknown simple type: byte[]". I've used this method of generating stubs and I've not received any errors before, granted all input variables have been simple types but I've used this to return arrays of custom objects. When I check the WSDL file the type is base64Binary.
Is there something I can use other than the byte array to pass the data in? Or is there some sort of setting that I am missing to allow the webservice to take it a byte array?
The best thing to do is probably just specify the parameter as a String. Base64 is ASCII representation of binary data.
you have the declare your method with String instead of byte[].
Than you can use the following snippet on the client side:
byte[] chunk = ...;
String data= Base64OutputStream.encodeAsString(chunk, 0, chunk.length, false, false);
UploadImage(data, name)
and on the server side you can use:
byte[] byteArray;
byteArray = Base64.decode(data);