Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > huh can`t send compressed string ??????? with webservice

Reply
Thread Tools

huh can`t send compressed string ??????? with webservice

 
 
M. Posseth
Guest
Posts: n/a
 
      04-02-2005
Hi ,

I have the following problem

i made an app that sends a xml formatted string across a network through a
webservice ( no i can`t use remoting as i need platform indepandancy )

So to reduce banwidth i implemented Adaptive Huffman this is working
great with the strings in test application`s

### compression method ###
Friend Function strCompress(ByVal strToCompress As String) As String

Dim Bytes() As Byte =
AdaptiveHuffmanProvider.Compress(Encoding.Unicode. GetBytes(strToCompress))

Return Encoding.Unicode.GetString(Bytes)

End Function

######################

this string is normally contained in strXml wich i pass over the webservice

<?xml version="1.0" encoding="utf-16"?>
<tirep>
<errcode>0</errcode>
<Session-ID>{726418b7-b317-47ec-8d3e-473dd07479c0}</Session-ID>
</tirep>


if this string is beeing compressed to 6d#2ti{zB ]?`?c<I: 
i get an error on the client side

System.Web.Services.Protocols.SoapException: Server was unable to process
request. --> There was an error generating the XML document. --> The
surrogate pair is invalid.
at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClient
Message message, WebResponse response, Stream responseStream, Boolean
asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
at NHSDataWebserviceTest.wsNHSBLW.NHSData.GetData(Str ing& strXML) in
C:\Documents and
Settings\Administrator\Desktop\NHSDataWebserviceTe stClient\NHSDataWebservice
Test\NHSData.vb:line 25
at NHSDataWebserviceTest.Form1.fobjXMLSendXMLRequest( String strXml,
Boolean& blnSucces) in C:\Documents and
Settings\Administrator\Desktop\NHSDataWebserviceTe stClient\NHSDataWebservice
Test\FrmMain.vb:line 370


here is my WSDL


<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.nohausystems.com/NHSService/NHSData"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://www.nohausystems.com/NHSService/NHSData"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified"
targetNamespace="http://www.nohausystems.com/NHSService/NHSData">
- <s:element name="GetData">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="strXML" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="GetDataResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="GetDataResult"
type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="strXML" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
- <wsdl:message name="GetDataSoapIn">
<wsdlart name="parameters" element="tns:GetData" />
</wsdl:message>
- <wsdl:message name="GetDataSoapOut">
<wsdlart name="parameters" element="tns:GetDataResponse" />
</wsdl:message>
- <wsdlortType name="NHSDataSoap">
- <wsdlperation name="GetData">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/">platform
independent interface wrapper , by specs of the TIREP Schnitstelle Dialog -
Business logic document of the New TIREP development team : Last mod to this
service binary 16-03-2005 , Made by : Michel Posseth [MCP] , info :
http://www.velocityreviews.com/forums/(E-Mail Removed)</documentation>
<wsdl:input message="tns:GetDataSoapIn" />
<wsdlutput message="tns:GetDataSoapOut" />
</wsdlperation>
</wsdlortType>
- <wsdl:binding name="NHSDataSoap" type="tns:NHSDataSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
- <wsdlperation name="GetData">
<soapperation
soapAction="http://www.nohausystems.com/NHSService/NHSData/GetData"
style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdlutput>
<soap:body use="literal" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
- <wsdl:service name="NHSData">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
- <wsdlort name="NHSDataSoap" binding="tns:NHSDataSoap">
<soap:address location="http://127.0.0.1:8080/nhsdata.asmx" />
</wsdlort>
</wsdl:service>
</wsdl:definitions>


if strXML contains

<?xml version="1.0" encoding="utf-16"?>
<tirep>
<errcode>0</errcode>
<Session-ID>{726418b7-b317-47ec-8d3e-473dd07479c0}</Session-ID>
</tirep>

then everything works fine

if strXML contains

6d#2ti{zB ]?`?c<I: 

i receive the error

what do i miss ?????












 
Reply With Quote
 
 
 
 
M. Posseth
Guest
Posts: n/a
 
      04-03-2005
Solved it

The trick is that you need to encodebase64 the string before passing it over
the webservice

this explodes the string some more but + - 20% smaller is still good enough
for me

another option would have been to subclass at the sender and receiver side ,
but then i lose my biggest advance , platform indepandancy

as some of my clients are using a Delphi component this is not accepatble
for me

for those of you interested in the technique


Dim bla As String = ">M95835 Brassica napus (clone BnCh25) endochitinase
gene, complete cds" & _

"TCATGAACGGCGCTCATATCATAATTACTTTTAAACATTCATAATTAAA ACTTACGTACGCTATATATCC" & _

"TTGACTATTCTTGCAACAACTTTACGAAAGGGGAAAATATAAACACACA AATCTACCAGTACTGTTTATT" & _

"GCACATATTCATTTTTTTTTGCTAAGTATTTATTGCACATATTCATACT CCACGGTCATATATCTAACTA" & _

"GGGAAAATATAAATTTGATGTGATTTAATTTAATTTAACATTCATTGAT TGATGTCTCCTGCATGTTGTA" & _

"CTATAAATACCTCTACTTGCCTAAAGATACCATAAAACTCAAAGCAAAA ATGAAGTCTTGTCTACTTCTC" & _

"TTTCTCATCTTCTCATTTCTTTTATCATTTTCCTTAGCCGAGCAATGTG GTCGACAAGCGGGAGGAGCTC" & _

"TCTGCCCCAACGGTCTATGCTGCAGCGAGTTCGGATGGTGCGGTGACAC CGAAGCTTACTGTAAGCAGCC" & _

"TGGCTGCCAAAGCCAGTGCGGTGGTACTCCTCCTGGCCCCACCGGTGAT CTTTCAGGCATCATTTCAAGA" & _

"TCTCAGTTCGACGACATGCTTAAACATAGAAATGATAATGCTTGTCCCG CTAGAGGTTTCTACACTTATG" & _

"ATGCCTTTATCAATGCCGCTAAGTCTTTCCCTGGCTTCGGCACCACCGG AGACACTGCCACAAGGAAGAA" & _

"AGAAATCGCTGCCTTCTTTGGTCAGACTTCCCACGAGACCACCGGTAAT AATTGATTATTTTCGTTTTTA" & _

"ACATAATTATTATTGTTTTATTTAGATGAAAAACAAAATCAAAATAACA ATTAAAAATATAACAAAATAA" & _

"TTATAAAACAATGTAATTTTTACTTTTATAATTACCATTTTTTTTGCTT AAAATTTTACGAATATAAGAA" & _

"TTTTCCAAAATGACTTAATATAGAAATCTATCAAAATTGTACTTCCTCT GTTTCATAATAAGTGTCATTC" & _

"TAGATTTTTTTTTTCTTGTTATAAAAAAAGTGTCACTTTACAATTCCAA AACAAATTATACTTATTTTCA" & _

"TCTTAAAATTAATTGCAAATTGTATTGGTTTTATAAATAATTTTATTTA TCTCAAATACTATTTATCTGG" & _

"AAAATGTAATTAATAACAACTTATATATATTTGCACTACTTTTGTGAAA AGTGTCAAAATGAAACTTATT" & _

"CAGAAACGGAGGGAATATAATACAAAACGTAACACATAAGTTTTCAACG TACATTTTCCCAAATTAAAAT" & _

"TAAACACGTAATGAATACAAAATAAGAAGTGTAATAAATTTAACGTAAT TAATAGATTAGACTTTTTTAT" & _

"AATTAACAAAAGTCTAATCTGTTACGCTATTAGACTTGTGACTTAATAA ACTAATGAAATGGACGATTGC" & _

"ATGTTGAAGGTGGGTGGGCCACAGCACCAGACGGACCATATTCATGGGG ATACTGTTTCAAACAAGAGCA" & _

"GAACCCTTCTTCAAACTACTGTTCACCGAGTGCCGAATGGCCATGCGCA TCTGGTAAAAGCTACTACGGA" & _

"AGAGGACCAATGCAGCTATCATGGAACTACAACTACGGACAGTGTGGAA GAGCCATCGGATCTGACTTAC" & _

"TCAACAACCCTGACCTTGTCTCCAACGATCCAGTGATCGCTTTCAAAGC CGCGATTTGGTTTTGGATGAC" & _

"ACCTCAGTCTCCAAAACCGTCGTGCCACGCCGTGATCGTCGGCCAGTGG CAGCCTTCGGATGCTGACCGT" & _

"GCCGCTGGGAGAGTACCGGGTTACGGTGTGATTACGAATATTATTAACG GTGGTTTAGAGTGTGGACGCG" & _

"GCCAAGACGCTAGAGTCGCGGATAGAATTGGATTTTACCAGAGGTACTG TAACATTCTTGGAGTTAATCC" & _

"TGGAGGTAACCTTGATTGTTACAACCAAAGGTCCTTTGCTTCTGTTAAC TTCTTCCTTGACGCTGCTATT" & _

"TAATAAGGAGTGTTATGCAGCTTTGTATCCAAAAGCAATAAGGGATTAA TATCAAACTAAATAAAACTCT" & _

"TTGTCGTATCTTATTCTTAGCTCCACTCCTCATTTTTTGAAGCATGTAC CAAATAACCTAAAGCTAATCT" & _

"TTCTCTAATGAGATAAACCAAACTAACAAATCTTGTTTTGATCGTTCAA CTAACTTAAAACTGAACTTTC" & _

"TAATTACATTTTCGGATTTTGTTTATGAGAGTTGGAATGGACAAAGCAA GATATAATTCTATTACATTTA" & _

"CAAGTTTCAAAACAGTTCAAGCGAGTTTCGCATAACATGTCGCTATCTC CAAGCATCATTTCAAGTGTAA" & _

"GCCTCGTAGTATAAAAATTTTGGCTACAATAACCGGTTTAGACCGAAGT AAACCAATCTAAAACTCCAAT" & _

"AGCCTCTATTTCTTAAACGTTACAAGACGAAAGTCAATTGACATTGAAC CAAGTGTGAACACTATTAAAG" & _

"AGAAAGCACTCTATTAAACCAAATGTTAGATGTAAACCAAAATTAAAAC TAAACCGAAAGTAAACCAAAA" & _

"ACTTATTGGGCACATTTACTGCGGGGACACAGAGTCCAACGACCTGTAA CCGCAGATGATTAATATCCGA" & _

"AAATATCTAAAAAGATCAGAGCACCGAACCAAAATATAAAGTGAAGATG ATGAAAAGCTGTTTCTCAATC" & _

"TTCTTCTCCATCTTCGTCTCCTCTAGTGATTTAGGGTTCTGCAACGACG AAGACATGGCTTTACTCGGCG" & _

"GCGTTCGCGATGTACCTGCTAATCAGAACAGCGGCGAGGTCGAGAGCCT CGCTCGTTTCGCCGTCGATGA" & _

"GCATAACAAGAAAGAGGTTCATCTCTCTCTCTCTCTCTCTCGATTAGTG ATCCAAATCGCGATTAGAGTA" & _

"AATTGTCATAGTCTCGCTTAGTATGTGATCTGATCATTGAGTGACGATT GTAGAATTCGCTGCTGGAGTT" & _

"TGCGAGGGTGGTGAGGCGAGACAGTTGTGCGGACGATGCATGACTGACG CTGAGATCGACTGCAGGCATG" & _

"CAA"

Dim Bytes() As Byte =
AdaptiveHuffmanProvider.Compress(Encoding.UTF8.Get Bytes(bla))

Dim test As String = System.Convert.ToBase64String(Bytes, 0, _

Bytes.Length)

MsgBox(Len(test))

MsgBox(test)' send this string over the wire ( through the webservice )

###############################

'receiver side

'make it a byt array again

Dim bytes2() As Byte = System.Convert.FromBase64String(test)

bytes2 = AdaptiveHuffmanProvider.Decompress(bytes2)

Dim decoded As String = Encoding.UTF8.GetString(bytes2)

MsgBox(Len(decoded))

' well here is the original string back

' P.S. this technique is verry fast



"M. Posseth" <(E-Mail Removed)> wrote in message
news:d2lucc$jud$(E-Mail Removed)...
> Hi ,
>
> I have the following problem
>
> i made an app that sends a xml formatted string across a network through a
> webservice ( no i can`t use remoting as i need platform indepandancy )
>
> So to reduce banwidth i implemented Adaptive Huffman this is working
> great with the strings in test application`s
>
> ### compression method ###
> Friend Function strCompress(ByVal strToCompress As String) As String
>
> Dim Bytes() As Byte =
> AdaptiveHuffmanProvider.Compress(Encoding.Unicode. GetBytes(strToCompress))
>
> Return Encoding.Unicode.GetString(Bytes)
>
> End Function
>
> ######################
>
> this string is normally contained in strXml wich i pass over the

webservice
>
> <?xml version="1.0" encoding="utf-16"?>
> <tirep>
> <errcode>0</errcode>
> <Session-ID>{726418b7-b317-47ec-8d3e-473dd07479c0}</Session-ID>
> </tirep>
>
>
> if this string is beeing compressed to 6d#2ti{zB ]?`?c<I: 
> i get an error on the client side
>
> System.Web.Services.Protocols.SoapException: Server was unable to process
> request. --> There was an error generating the XML document. --> The
> surrogate pair is invalid.
> at
>

System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClient
> Message message, WebResponse response, Stream responseStream, Boolean
> asyncCall)
> at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
> methodName, Object[] parameters)
> at NHSDataWebserviceTest.wsNHSBLW.NHSData.GetData(Str ing& strXML) in
> C:\Documents and
>

Settings\Administrator\Desktop\NHSDataWebserviceTe stClient\NHSDataWebservice
> Test\NHSData.vb:line 25
> at NHSDataWebserviceTest.Form1.fobjXMLSendXMLRequest( String strXml,
> Boolean& blnSucces) in C:\Documents and
>

Settings\Administrator\Desktop\NHSDataWebserviceTe stClient\NHSDataWebservice
> Test\FrmMain.vb:line 370
>
>
> here is my WSDL
>
>
> <?xml version="1.0" encoding="utf-8" ?>
> - <wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:s="http://www.w3.org/2001/XMLSchema"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:tns="http://www.nohausystems.com/NHSService/NHSData"
> xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
> xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
> targetNamespace="http://www.nohausystems.com/NHSService/NHSData"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
> - <wsdl:types>
> - <s:schema elementFormDefault="qualified"
> targetNamespace="http://www.nohausystems.com/NHSService/NHSData">
> - <s:element name="GetData">
> - <s:complexType>
> - <s:sequence>
> <s:element minOccurs="0" maxOccurs="1" name="strXML" type="s:string" />
> </s:sequence>
> </s:complexType>
> </s:element>
> - <s:element name="GetDataResponse">
> - <s:complexType>
> - <s:sequence>
> <s:element minOccurs="1" maxOccurs="1" name="GetDataResult"
> type="s:boolean" />
> <s:element minOccurs="0" maxOccurs="1" name="strXML" type="s:string" />
> </s:sequence>
> </s:complexType>
> </s:element>
> </s:schema>
> </wsdl:types>
> - <wsdl:message name="GetDataSoapIn">
> <wsdlart name="parameters" element="tns:GetData" />
> </wsdl:message>
> - <wsdl:message name="GetDataSoapOut">
> <wsdlart name="parameters" element="tns:GetDataResponse" />
> </wsdl:message>
> - <wsdlortType name="NHSDataSoap">
> - <wsdlperation name="GetData">
> <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">platform
> independent interface wrapper , by specs of the TIREP Schnitstelle

Dialog -
> Business logic document of the New TIREP development team : Last mod to

this
> service binary 16-03-2005 , Made by : Michel Posseth [MCP] , info :
> (E-Mail Removed)</documentation>
> <wsdl:input message="tns:GetDataSoapIn" />
> <wsdlutput message="tns:GetDataSoapOut" />
> </wsdlperation>
> </wsdlortType>
> - <wsdl:binding name="NHSDataSoap" type="tns:NHSDataSoap">
> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
> style="document" />
> - <wsdlperation name="GetData">
> <soapperation
> soapAction="http://www.nohausystems.com/NHSService/NHSData/GetData"
> style="document" />
> - <wsdl:input>
> <soap:body use="literal" />
> </wsdl:input>
> - <wsdlutput>
> <soap:body use="literal" />
> </wsdlutput>
> </wsdlperation>
> </wsdl:binding>
> - <wsdl:service name="NHSData">
> <documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
> - <wsdlort name="NHSDataSoap" binding="tns:NHSDataSoap">
> <soap:address location="http://127.0.0.1:8080/nhsdata.asmx" />
> </wsdlort>
> </wsdl:service>
> </wsdl:definitions>
>
>
> if strXML contains
>
> <?xml version="1.0" encoding="utf-16"?>
> <tirep>
> <errcode>0</errcode>
> <Session-ID>{726418b7-b317-47ec-8d3e-473dd07479c0}</Session-ID>
> </tirep>
>
> then everything works fine
>
> if strXML contains
>
> 6d#2ti{zB ]?`?c<I: 
>
> i receive the error
>
> what do i miss ?????
>
>
>
>
>
>
>
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with decoding a compressed string keith_g Ruby 1 12-03-2007 02:53 AM
Could we send a compressed file (.zip) to server by web service? ad ASP .Net 6 09-11-2005 05:32 AM
Weirdness... huh? (specified web server not running ASP.NET version 1.1) VB Programmer ASP .Net 1 06-12-2004 12:14 AM
doc types! huh? some dude somewhere HTML 6 01-03-2004 10:32 PM
Output parameters undefined? Huh? Jim Owen ASP .Net 1 10-22-2003 03:35 PM



Advertisments