Home All Groups Group Topic Archive Search About

error passing byte[] of encrypted data to Web Service

Author
28 May 2005 1:44 PM
ChuckD_Duncan
Have Web Service:  bool Login( byte[] A, byte[] B );
If I just send a couple of simple strings, it works fine ... as in:
     byte[] A = Encoding.Default.GetBytes("First");
     byte[] B = Encoding.Default.GetBytes("Last");

but changing A to a 100+ byte encypted sequence of bytes, causes an
error:

An unhandled exception of type
'System.Web.Services.Protocols.SoapException' occurred in
system.web.services.dll

Additional information: Server was unable to process request. --> Object
reference not set to an instance of an object.

Obviously happening at the SOAP level.  (Server is Win 2K .NET Framework
1.0, client is XP, .NET/Latest, but tried it on localhost (XP) )

Any thoughts?? 

Thanks in advance.
Chuck

Author
29 May 2005 3:00 PM
Yunus Emre ALPÖZEN [MCSD.NET]
My advice uy to use strings instead of byte arrays..

But, as error indicating, it is a null pointer exception. There is no limit
with byte arrays. Just check if you successfully construct your byte
arrays..

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET

Show quoteHide quote
"ChuckD_Duncan" <cduncan@nospam.guardianangelcorp.com> wrote in message
news:5d96ef79d912558faf5284a971dad2ac@localhost.talkaboutsoftware.com...
> Have Web Service:  bool Login( byte[] A, byte[] B );
> If I just send a couple of simple strings, it works fine ... as in:
>     byte[] A = Encoding.Default.GetBytes("First");
>     byte[] B = Encoding.Default.GetBytes("Last");
>
> but changing A to a 100+ byte encypted sequence of bytes, causes an
> error:
>
> An unhandled exception of type
> 'System.Web.Services.Protocols.SoapException' occurred in
> system.web.services.dll
>
> Additional information: Server was unable to process request. --> Object
> reference not set to an instance of an object.
>
> Obviously happening at the SOAP level.  (Server is Win 2K .NET Framework
> 1.0, client is XP, .NET/Latest, but tried it on localhost (XP) )
>
> Any thoughts??
>
> Thanks in advance.
> Chuck
>
Author
29 May 2005 8:17 PM
ChuckD_Duncan
Thanks... I tried converting the byte array to a string which succeeds but
fails to send ... because (I suspect) that the conversions are binary and
characters in the string end up with every conceivable value, perhaps
terminating nulls or some such??  I am wondering if MIME encoding is
necessary in these cases. 
Still working on the problem, but thanks again for your advice.

Chuck
Author
29 May 2005 8:53 PM
ChuckD_Duncan
passing something simple like:
       bool result = Sample("first", "second");
works fine... but when the two args are replaced by encrypted strings, I
get the same "object not set to an instance" error message as in the start
of this thread.

     bool result = Sample( szEncryp, szXMLPublicKey);

also blows up if the first parm is NOT encrypted at all, just "xyz".  The
XML string is in fact a well-formed XML:
     string szXMLPublicString = provider_alg.GetXMLString(false); // and
can be viewed and verified as a valid XML string.

Help??
Author
30 May 2005 9:29 AM
Dominick Baier [DevelopMentor]
Hello ChuckD_Duncan,

try converting your encrypted strings to Base64 prior to sending

string s = Convert.ToBase64(byte[])

this should be done automatically upon serialization by the proxy infrastructure
(what datatype ends up in your wsdl document) ??

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

Show quoteHide quote
> passing something simple like:
> bool result = Sample("first", "second");
> works fine... but when the two args are replaced by encrypted strings,
> I
> get the same "object not set to an instance" error message as in the
> start of this thread.
>
> bool result = Sample( szEncryp, szXMLPublicKey);
>
> also blows up if the first parm is NOT encrypted at all, just "xyz".
> The
> XML string is in fact a well-formed XML:
> string szXMLPublicString = provider_alg.GetXMLString(false); //
> and
> can be viewed and verified as a valid XML string.
> Help??
>
Author
30 May 2005 5:59 PM
Yunus Emre ALPÖZEN [MCSD.NET]
U are right. Converting Base64 should fix it. To overcome this issue, I
prefer to implement a class and mark it serializable and embed my data in
it. Conversion is done automatically. I used this method for secure file
transfer over SSL in web services. It works perfectly...

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET

Show quoteHide quote
"Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com>
wrote in message news:421237632530493895783323@news.microsoft.com...
> Hello ChuckD_Duncan,
>
> try converting your encrypted strings to Base64 prior to sending
>
> string s = Convert.ToBase64(byte[])
>
> this should be done automatically upon serialization by the proxy
> infrastructure (what datatype ends up in your wsdl document) ??
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
>> passing something simple like:
>> bool result = Sample("first", "second");
>> works fine... but when the two args are replaced by encrypted strings,
>> I
>> get the same "object not set to an instance" error message as in the
>> start of this thread.
>>
>> bool result = Sample( szEncryp, szXMLPublicKey);
>>
>> also blows up if the first parm is NOT encrypted at all, just "xyz".
>> The
>> XML string is in fact a well-formed XML:
>> string szXMLPublicString = provider_alg.GetXMLString(false); //
>> and
>> can be viewed and verified as a valid XML string.
>> Help??
>>
>
>
>
Author
31 May 2005 10:28 PM
ChuckD_Duncan
Dom, this works great... except I'm afraid I'm a bit at a loss on how to
get the original string back on the other end of the pipe.  There must be
a Convert before I bust it up into bytes again, I guess???

Help?

Thanks again.
Author
1 Jun 2005 7:25 AM
Dominick Baier [DevelopMentor]
Hello ChuckD_Duncan,

ok - you are using a string variable now?

Convert.FromBase64 is your friend on the server side.

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

Show quoteHide quote
> Dom, this works great... except I'm afraid I'm a bit at a loss on how
> to get the original string back on the other end of the pipe.  There
> must be a Convert before I bust it up into bytes again, I guess???
>
> Help?
>
> Thanks again.
>
Author
30 May 2005 7:56 PM
ChuckD_Duncan
Thanks Dom... that seems to have solved the problem!!!

Chuck
Author
1 Jun 2005 12:15 PM
ChuckD_Duncan
Dom, this works great... except I'm afraid I'm a bit at a loss on how to
get the original string back on the other end of the pipe.  There must be
a Convert before I bust it up into bytes again, I guess???

Help?

Thanks again.