[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [xmlblaster-devel] question in connect to /xmlBlaster/AppletServletin c++ client
Hi Peng,
after looking at your problem i think that the AppletServlet
is no good way to serve other programming languages than Java
as it uses a java object stream as you noted.
In my opinion using our SOCKET protocol would be the suitable
approach to deliver messages and exceptions in a generic way.
You would end up implementing a new 'SocketServlet' which
uses
http://www.xmlblaster.org/xmlBlaster/doc/requirements/protocol.socket.html
as a transport format.
Like this it is reusable for all languages and we already have such
SOCKET render/generate tools for C, C++ and Java (and beta in Python).
rgds
Marcel
peng at qcet.cn wrote:
>I use code in src\c++\util\Base64.cpp to encode and decode the code;
>but I find that the Base64 data come from AppletServlet is an objectstream
>that only can be reader with readobject in java;
>
>my code still get the error:
>
>AnsiString httpstr=AnsiString("POST /xmlBlaster/AppletServlet HTTP/1.1\r\n");
>httpstr=httpstr+"cookie: "+Edit1->Text+"\r\n";
>httpstr=httpstr+"Cache-Control: no-cache\r\n";
>httpstr=httpstr+"Pragma: no-cache\r\n";
>httpstr=httpstr+"Connection: keep-alive\r\n";
>httpstr=httpstr+"ActionType: connect\r\n";
>......
>httpstr=httpstr+"Content-Length: 9\r\n";
>httpstr=httpstr+"\r\n";
>// * The format:
>// * oid + \0 + key + '\0' + qos + '\0' + content: length = oid + key + qos + content + 3
>IdTCPClient1->Write(httpstr);
>httpstr="\0\0<qos/>\0";
>
>std::vector<unsigned char> benc;
>for(int a=0;a<httpstr.Length();a++) benc.push_back(httpstr[a]);
>std::string enc=Encode(benc);
>IdTCPClient1->Write(AnsiString(enc.c_str()));
>
>[2005-9-27 15:48:58 WARN http-8080-Processor24 org.xmlBlaster.protocol.http.app
>letproxy.AppletServlet-127.0.0.1-3DDBFCBE1B2737065E8EFF56189D5834] Caught XmlBla
>ster Exception: XmlBlasterException errorCode=[user.configuration] serverSideExc
>eption=false location=[org.xmlBlaster.protocol.http.appletproxy.AppletServlet-12
>7.0.0.1-3DDBFCBE1B2737065E8EFF56189D5834] message=[#1.0.6 Missing connect QoS. P
>ass xmlBlaster.connectQos='<qos> ... </qos>' with your URL in your POST in a hid
>den form field or in your cookie. : ] [See URL http://www.xmlblaster.org/xmlBlas
>ter/doc/requirements/admin.errorcodes.listing.html#user.configuration]
>
> How I can build the post data so AppletServlet read them as an object?
>and How I can read the object in c++ client?
>
>Thank you!
>
>peng
>
>
>
>
>
>
>
>>peng at qcet.cn wrote:
>>
>>
>>
>>>Hello:
>>> I try to connect to /xmlBlaster/AppletServlet in my c++ client;
>>>
>>>my code like this:
>>>
>>>AnsiString httpstr=AnsiString("POST /xmlBlaster/AppletServlet HTTP/1.1\r\n");
>>>httpstr=httpstr+"cookie: \r\n";
>>>httpstr=httpstr+"Cache-Control: no-cache\r\n";
>>>httpstr=httpstr+"Pragma: no-cache\r\n";
>>>httpstr=httpstr+"Connection: keep-alive\r\n";
>>>httpstr=httpstr+"ActionType: dummyToCreateASessionId\r\n";
>>>httpstr=httpstr+"BinaryProtocol: true\r\n";
>>>httpstr=httpstr+"Data-Length: 3\r\n";
>>>httpstr=httpstr+"User-Agent: Java/1.5.0\r\n";
>>>httpstr=httpstr+"Host: 192.168.1.102:8080\r\n";
>>>httpstr=httpstr+"Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n";
>>>httpstr=httpstr+"Content-type: application/x-www-form-urlencoded\r\n";
>>>httpstr=httpstr+"Content-Length: 0\r\n";
>>>httpstr=httpstr+"\r\n";
>>>
>>>IdTCPClient1->Write(httpstr); //IdTCPClient1 is a indy Component
>>>Memo1->Lines->Add(IdTCPClient1->ReadLn(EOL,2000));
>>>
>>> get the answer from AppletServlet:
>>>
>>>HTTP/1.1 200 OK
>>>Server: Apache-Coyote/1.1
>>>Set-Cookie: JSESSIONID=D30D21BC31DE997291BEC37F654A0E77; Path=/xmlBlaster
>>>Content-Type: text/plain;charset=ISO-8859-1
>>>Transfer-Encoding: chunked
>>>Date: Mon, 26 Sep 2005 08:08:43 GMT
>>>
>>>46
>>>AAAAAAAXZHVtbXlUb0NyZWF0ZUFTZXNzaW9uSWQAAAAAABBPSy0xMTI3NzIyMTIzMDYy
>>>
>>>0
>>>
>>>what the last 4 lines mean(from "46"line to "0"line)?
>>>How I can decode the line "AAAAAAAXZHVtbXlUb0NyZWF0ZUFTZXNzaW9uSWQAAAAAABBPSy0xMTI3NzIyMTIzMDYy "?
>>>
>>>
>>>
>>>
>>This is base64 encoded, please see
>>xmlBlaster/src/java/org/xmlBlaster/protocol/http/appletproxy/AppletServlet.java
>>about the implemented protocol.
>>
>>I have commited an extended EncodableData.java which you can use (get it
>>
>>
>>from svn):
>
>
>>java org.xmlBlaster.util.EncodableData
>>AAAAAAAXZHVtbXlUb0NyZWF0ZUFTZXNzaW9uSWQAAAAAABBPSy0xMTI3NzIyMTIzMDYy
>>
>>'AAAAAAAXZHVtbXlUb0NyZWF0ZUFTZXNzaW9uSWQAAAAAABBPSy0xMTI3NzIyMTIzMDYy'
>>-> 'dummyToCreateASessionIdOK-1127722123062'
>>
>>
>>
>>
>>>//--------------------------------------------------------------------------------------
>>>and then I send a "connect" command to AppletServlet:
>>>
>>>AnsiString httpstr=AnsiString("POST /xmlBlaster/AppletServlet HTTP/1.1\r\n");
>>>httpstr=httpstr+"cookie: "+Edit1->Text+"\r\n";
>>>httpstr=httpstr+"Cache-Control: no-cache\r\n";
>>>httpstr=httpstr+"Pragma: no-cache\r\n";
>>>httpstr=httpstr+"Connection: keep-alive\r\n";
>>>httpstr=httpstr+"ActionType: connect\r\n";
>>>httpstr=httpstr+"BinaryProtocol: true\r\n";
>>>httpstr=httpstr+"Data-Length: 9\r\n";
>>>httpstr=httpstr+"User-Agent: Java/1.5.0\r\n";
>>>httpstr=httpstr+"Host: 192.168.1.102:8080\r\n";
>>>httpstr=httpstr+"Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n";
>>>httpstr=httpstr+"Content-type: application/x-www-form-urlencoded\r\n";
>>>httpstr=httpstr+"Content-Length: 9\r\n";
>>>httpstr=httpstr+"\r\n";
>>>
>>>// * The format:
>>>// * oid + \0 + key + '\0' + qos + '\0' + content: length = oid + key + qos + content + 3
>>>
>>>httpstr=httpstr+"\0\0<qos/>\0";
>>>IdTCPClient1->Write(httpstr);
>>>
>>>in tomcat, I get an err :
>>>
>>>[2005-9-26 16:14:44 WARN http-8080-Processor21 org.xmlBlaster.protocol.http.app
>>>letproxy.AppletServlet-127.0.0.1-7F3F49873489FC60E635B12D5991DF1F] Caught XmlBla
>>>ster Exception: XmlBlasterException errorCode=[user.configuration] serverSideExc
>>>eption=false location=[org.xmlBlaster.protocol.http.appletproxy.AppletServlet-12
>>>7.0.0.1-7F3F49873489FC60E635B12D5991DF1F] message=[#1.0.6 Missing connect QoS. P
>>>ass xmlBlaster.connectQos='<qos> ... </qos>' with your URL in your POST in a hid
>>>den form field or in your cookie. : ] [See URL http://www.xmlblaster.org/xmlBlas
>>>ter/doc/requirements/admin.errorcodes.listing.html#user.configuration]
>>>
>>>How I can encode and post the qos ?
>>>
>>>
>>>
>>>
>>Additionally you could use a http sniffer (for example a plugin for
>>firefox) to see what exactly is transmitted.
>>
>>rgds,
>>Marcel
>>
>>
>>
>>>thank you!
>>>
>>>peng
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
>
>
>
>