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

Discussion in 'ASP .Net Web Services' started by M. Posseth, Apr 2, 2005.

  1. M. Posseth

    M. Posseth Guest

    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.SoapHttpClientProtocol.ReadResponse(SoapClient
    Message message, WebResponse response, Stream responseStream, Boolean
    asyncCall)
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
    methodName, Object[] parameters)
    at NHSDataWebserviceTest.wsNHSBLW.NHSData.GetData(String& strXML) in
    C:\Documents and
    Settings\Administrator\Desktop\NHSDataWebserviceTestClient\NHSDataWebservice
    Test\NHSData.vb:line 25
    at NHSDataWebserviceTest.Form1.fobjXMLSendXMLRequest(String strXml,
    Boolean& blnSucces) in C:\Documents and
    Settings\Administrator\Desktop\NHSDataWebserviceTestClient\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">
    <wsdl:part name="parameters" element="tns:GetData" />
    </wsdl:message>
    - <wsdl:message name="GetDataSoapOut">
    <wsdl:part name="parameters" element="tns:GetDataResponse" />
    </wsdl:message>
    - <wsdl:portType name="NHSDataSoap">
    - <wsdl:eek:peration 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 :
    </documentation>
    <wsdl:input message="tns:GetDataSoapIn" />
    <wsdl:eek:utput message="tns:GetDataSoapOut" />
    </wsdl:eek:peration>
    </wsdl:portType>
    - <wsdl:binding name="NHSDataSoap" type="tns:NHSDataSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
    style="document" />
    - <wsdl:eek:peration name="GetData">
    <soap:eek:peration
    soapAction="http://www.nohausystems.com/NHSService/NHSData/GetData"
    style="document" />
    - <wsdl:input>
    <soap:body use="literal" />
    </wsdl:input>
    - <wsdl:eek:utput>
    <soap:body use="literal" />
    </wsdl:eek:utput>
    </wsdl:eek:peration>
    </wsdl:binding>
    - <wsdl:service name="NHSData">
    <documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
    - <wsdl:port name="NHSDataSoap" binding="tns:NHSDataSoap">
    <soap:address location="http://127.0.0.1:8080/nhsdata.asmx" />
    </wsdl:port>
    </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 ?????
    M. Posseth, Apr 2, 2005
    #1
    1. Advertising

  2. M. Posseth

    M. Posseth Guest

    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" & _

    "TCATGAACGGCGCTCATATCATAATTACTTTTAAACATTCATAATTAAAACTTACGTACGCTATATATCC" & _

    "TTGACTATTCTTGCAACAACTTTACGAAAGGGGAAAATATAAACACACAAATCTACCAGTACTGTTTATT" & _

    "GCACATATTCATTTTTTTTTGCTAAGTATTTATTGCACATATTCATACTCCACGGTCATATATCTAACTA" & _

    "GGGAAAATATAAATTTGATGTGATTTAATTTAATTTAACATTCATTGATTGATGTCTCCTGCATGTTGTA" & _

    "CTATAAATACCTCTACTTGCCTAAAGATACCATAAAACTCAAAGCAAAAATGAAGTCTTGTCTACTTCTC" & _

    "TTTCTCATCTTCTCATTTCTTTTATCATTTTCCTTAGCCGAGCAATGTGGTCGACAAGCGGGAGGAGCTC" & _

    "TCTGCCCCAACGGTCTATGCTGCAGCGAGTTCGGATGGTGCGGTGACACCGAAGCTTACTGTAAGCAGCC" & _

    "TGGCTGCCAAAGCCAGTGCGGTGGTACTCCTCCTGGCCCCACCGGTGATCTTTCAGGCATCATTTCAAGA" & _

    "TCTCAGTTCGACGACATGCTTAAACATAGAAATGATAATGCTTGTCCCGCTAGAGGTTTCTACACTTATG" & _

    "ATGCCTTTATCAATGCCGCTAAGTCTTTCCCTGGCTTCGGCACCACCGGAGACACTGCCACAAGGAAGAA" & _

    "AGAAATCGCTGCCTTCTTTGGTCAGACTTCCCACGAGACCACCGGTAATAATTGATTATTTTCGTTTTTA" & _

    "ACATAATTATTATTGTTTTATTTAGATGAAAAACAAAATCAAAATAACAATTAAAAATATAACAAAATAA" & _

    "TTATAAAACAATGTAATTTTTACTTTTATAATTACCATTTTTTTTGCTTAAAATTTTACGAATATAAGAA" & _

    "TTTTCCAAAATGACTTAATATAGAAATCTATCAAAATTGTACTTCCTCTGTTTCATAATAAGTGTCATTC" & _

    "TAGATTTTTTTTTTCTTGTTATAAAAAAAGTGTCACTTTACAATTCCAAAACAAATTATACTTATTTTCA" & _

    "TCTTAAAATTAATTGCAAATTGTATTGGTTTTATAAATAATTTTATTTATCTCAAATACTATTTATCTGG" & _

    "AAAATGTAATTAATAACAACTTATATATATTTGCACTACTTTTGTGAAAAGTGTCAAAATGAAACTTATT" & _

    "CAGAAACGGAGGGAATATAATACAAAACGTAACACATAAGTTTTCAACGTACATTTTCCCAAATTAAAAT" & _

    "TAAACACGTAATGAATACAAAATAAGAAGTGTAATAAATTTAACGTAATTAATAGATTAGACTTTTTTAT" & _

    "AATTAACAAAAGTCTAATCTGTTACGCTATTAGACTTGTGACTTAATAAACTAATGAAATGGACGATTGC" & _

    "ATGTTGAAGGTGGGTGGGCCACAGCACCAGACGGACCATATTCATGGGGATACTGTTTCAAACAAGAGCA" & _

    "GAACCCTTCTTCAAACTACTGTTCACCGAGTGCCGAATGGCCATGCGCATCTGGTAAAAGCTACTACGGA" & _

    "AGAGGACCAATGCAGCTATCATGGAACTACAACTACGGACAGTGTGGAAGAGCCATCGGATCTGACTTAC" & _

    "TCAACAACCCTGACCTTGTCTCCAACGATCCAGTGATCGCTTTCAAAGCCGCGATTTGGTTTTGGATGAC" & _

    "ACCTCAGTCTCCAAAACCGTCGTGCCACGCCGTGATCGTCGGCCAGTGGCAGCCTTCGGATGCTGACCGT" & _

    "GCCGCTGGGAGAGTACCGGGTTACGGTGTGATTACGAATATTATTAACGGTGGTTTAGAGTGTGGACGCG" & _

    "GCCAAGACGCTAGAGTCGCGGATAGAATTGGATTTTACCAGAGGTACTGTAACATTCTTGGAGTTAATCC" & _

    "TGGAGGTAACCTTGATTGTTACAACCAAAGGTCCTTTGCTTCTGTTAACTTCTTCCTTGACGCTGCTATT" & _

    "TAATAAGGAGTGTTATGCAGCTTTGTATCCAAAAGCAATAAGGGATTAATATCAAACTAAATAAAACTCT" & _

    "TTGTCGTATCTTATTCTTAGCTCCACTCCTCATTTTTTGAAGCATGTACCAAATAACCTAAAGCTAATCT" & _

    "TTCTCTAATGAGATAAACCAAACTAACAAATCTTGTTTTGATCGTTCAACTAACTTAAAACTGAACTTTC" & _

    "TAATTACATTTTCGGATTTTGTTTATGAGAGTTGGAATGGACAAAGCAAGATATAATTCTATTACATTTA" & _

    "CAAGTTTCAAAACAGTTCAAGCGAGTTTCGCATAACATGTCGCTATCTCCAAGCATCATTTCAAGTGTAA" & _

    "GCCTCGTAGTATAAAAATTTTGGCTACAATAACCGGTTTAGACCGAAGTAAACCAATCTAAAACTCCAAT" & _

    "AGCCTCTATTTCTTAAACGTTACAAGACGAAAGTCAATTGACATTGAACCAAGTGTGAACACTATTAAAG" & _

    "AGAAAGCACTCTATTAAACCAAATGTTAGATGTAAACCAAAATTAAAACTAAACCGAAAGTAAACCAAAA" & _

    "ACTTATTGGGCACATTTACTGCGGGGACACAGAGTCCAACGACCTGTAACCGCAGATGATTAATATCCGA" & _

    "AAATATCTAAAAAGATCAGAGCACCGAACCAAAATATAAAGTGAAGATGATGAAAAGCTGTTTCTCAATC" & _

    "TTCTTCTCCATCTTCGTCTCCTCTAGTGATTTAGGGTTCTGCAACGACGAAGACATGGCTTTACTCGGCG" & _

    "GCGTTCGCGATGTACCTGCTAATCAGAACAGCGGCGAGGTCGAGAGCCTCGCTCGTTTCGCCGTCGATGA" & _

    "GCATAACAAGAAAGAGGTTCATCTCTCTCTCTCTCTCTCTCGATTAGTGATCCAAATCGCGATTAGAGTA" & _

    "AATTGTCATAGTCTCGCTTAGTATGTGATCTGATCATTGAGTGACGATTGTAGAATTCGCTGCTGGAGTT" & _

    "TGCGAGGGTGGTGAGGCGAGACAGTTGTGCGGACGATGCATGACTGACGCTGAGATCGACTGCAGGCATG" & _

    "CAA"

    Dim Bytes() As Byte =
    AdaptiveHuffmanProvider.Compress(Encoding.UTF8.GetBytes(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" <> wrote in message
    news:d2lucc$jud$...
    > 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.SoapHttpClientProtocol.ReadResponse(SoapClient
    > Message message, WebResponse response, Stream responseStream, Boolean
    > asyncCall)
    > at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
    > methodName, Object[] parameters)
    > at NHSDataWebserviceTest.wsNHSBLW.NHSData.GetData(String& strXML) in
    > C:\Documents and
    >

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

    Settings\Administrator\Desktop\NHSDataWebserviceTestClient\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">
    > <wsdl:part name="parameters" element="tns:GetData" />
    > </wsdl:message>
    > - <wsdl:message name="GetDataSoapOut">
    > <wsdl:part name="parameters" element="tns:GetDataResponse" />
    > </wsdl:message>
    > - <wsdl:portType name="NHSDataSoap">
    > - <wsdl:eek:peration 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 :
    > </documentation>
    > <wsdl:input message="tns:GetDataSoapIn" />
    > <wsdl:eek:utput message="tns:GetDataSoapOut" />
    > </wsdl:eek:peration>
    > </wsdl:portType>
    > - <wsdl:binding name="NHSDataSoap" type="tns:NHSDataSoap">
    > <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
    > style="document" />
    > - <wsdl:eek:peration name="GetData">
    > <soap:eek:peration
    > soapAction="http://www.nohausystems.com/NHSService/NHSData/GetData"
    > style="document" />
    > - <wsdl:input>
    > <soap:body use="literal" />
    > </wsdl:input>
    > - <wsdl:eek:utput>
    > <soap:body use="literal" />
    > </wsdl:eek:utput>
    > </wsdl:eek:peration>
    > </wsdl:binding>
    > - <wsdl:service name="NHSData">
    > <documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
    > - <wsdl:port name="NHSDataSoap" binding="tns:NHSDataSoap">
    > <soap:address location="http://127.0.0.1:8080/nhsdata.asmx" />
    > </wsdl:port>
    > </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 ?????
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    M. Posseth, Apr 3, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Owen

    Output parameters undefined? Huh?

    Jim Owen, Oct 22, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    418
    Rajesh.V
    Oct 22, 2003
  2. VB Programmer
    Replies:
    1
    Views:
    354
    Chris Moore
    Jun 12, 2004
  3. ad
    Replies:
    6
    Views:
    3,214
  4. M.Posseth

    huh can`t pass datatable ????

    M.Posseth, Feb 24, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    141
    M. Posseth
    Feb 24, 2005
  5. keith_g
    Replies:
    1
    Views:
    194
    MonkeeSage
    Dec 3, 2007
Loading...

Share This Page