Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Parameter Serializer nullifies incoming byte array (x-post)

Reply
Thread Tools

Parameter Serializer nullifies incoming byte array (x-post)

 
 
irwin.williams@gmail.com
Guest
Posts: n/a
 
      03-13-2006
Hi, i posted this message in the WSE group
(http://groups.google.com/group/micro...s.enhancements)
but got no response.

Hello
I am using web services to send arrays of bytes inside of messages.
The actual service i am using is hosted outside of IIS using Aaron
Skonnard's HTTPSys transport
http://pluralsight.com/blogs/aaron/a.../14/15571.aspx, and i

am also using Custom Soap Filters to edit specific messages.

When i send a message containing properties which may themselves
contain arrays of bytes the actual message as a parameter of given
methods on the service contains the properties, except that the actual
array is empty (size = 0).


Via investigation of the methods called on the service (which extends
SoapService from WSE 3.0) , I was aided greatly by Lutz's .Net
Reflector http://www.aisto.com/roeder/dotnet/, I have found that the
call to Invoke the method on the webservice somehow causes the byte
array inside of the soap envelope to be made empty.


I have produced a small project, which i hope explains the exact issue
i am trying to deal with. Please see the code below. Any light shed
on this matter would be most appreciated.


using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
using System.Xml.Serialization;
using Microsoft.Web.Services3;
using System.Reflection;
using System.Web.Services.Description;


namespace ParameterSerializerTest
{
[WebService(Name = "ParameterSerializerNullBytes", Namespace =
tempnamespace)]
public class ParameterSerializerNullBytes
{
public const string tempnamespace =
"http://myNamespace.org";


public static void Main(string[] args)
{
#region Create Attachments
SpecialAttachment spa = new
SpecialAttachment();
spa.content = new byte[] { 1, 2, 3, 4, 5, 6, 7,
8, 9, 0 };
spa.name = "speelunks";
AttachmentContainer atc = new
AttachmentContainer();
atc.attachments = new
List<SpecialAttachment>();
atc.attachments.Add(spa);
atc.containername = "containerforspeelunks";
#endregion


SoapEnvelope env = new SoapEnvelope();
env.SetBodyObject(atc, tempnamespace);


#region Use reflection to get access to the
Parameter Serializer
Type receiverType =
typeof(ParameterSerializerNullBytes);
MethodInfo selectedMethodInfo =
receiverType.GetMethod("Deliver");
LogicalMethodInfo logicalMethodInfo = new
LogicalMethodInfo(selectedMethodInfo);
SoapServerMethod selectedMethod = new
SoapServerMethod(receiverType,
logicalMethodInfo);


#endregion


#region Use the serializer to get the
AttachmentContainer out of the
SoapEnvelope
XmlReader reader = env.GetBodyReader();
object[] oArray = null;
reader.ReadStartElement(reader.LocalName,
reader.NamespaceURI);
reader.MoveToContent();
oArray =
(object[])selectedMethod.ParameterSerializer.Deserialize(re ader,
(selectedMethod.BindingUse == SoapBindingUse.Encoded) ?
env.CurrentSoap.EncodingStyle : null);
reader.Close();
#endregion


AttachmentContainer atcReturned = oArray[0] as
AttachmentContainer;


Console.WriteLine("content byte size BEFORE
inserting into the
SoapEnvelope: "+ Environment.NewLine +
atc.attachments[0].content.Length);


Console.WriteLine("content byte size AFTER
using the serializer:" +
Environment.NewLine + atcReturned.attachments[0].content.Length);


AttachmentContainer atcFromEnvelope =
(AttachmentContainer)env.GetBodyObject(typeof(Atta chmentContainer),
tempnamespace);
Console.WriteLine("content byte size AFTER
inserting into the
SoapEnvelope:" + Environment.NewLine +
atcFromEnvelope.attachments[0].content.Length);


Console.Read();
}


[SoapDocumentMethodAttribute("Deliver",
Use = SoapBindingUse.Literal,
ParameterStyle = SoapParameterStyle.Bare)]
public void Deliver([XmlElement(Namespace =
tempnamespace,
ElementName = "AttachmentContainer")] AttachmentContainer atc)
{
}
}


[XmlType(Namespace =
ParameterSerializerNullBytes.tempnamespace,
TypeName = "SpecialAttachment")]
public class SpecialAttachment
{
[XmlElement(typeof(byte[]))]
public byte[] content;
[XmlElement()]
public string name;
}


[XmlType(Namespace =
ParameterSerializerNullBytes.tempnamespace,
TypeName = "AttachmentContainer")]
public class AttachmentContainer
{
[XmlArray()]
public List<SpecialAttachment> attachments;
[XmlElement()]
public string containername;
}

}

 
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
convert form byte[4] to Int32 while retaining the binary value of the byte array jeff@foundrymusic.com C++ 20 09-07-2009 08:54 PM
The connection to the server has failed. Account: 'incoming.yahoo.verzon.net', Server: 'incoming.yahoo.verizon.net', Protocol: POP3, Port: 110, Secure(SSL): No, Socket Error: 10061, Error Number: 0x800CCC0E Michael Bower Computer Support 3 10-01-2006 03:44 PM
Converting a Primative byte array to a Byte array object Kirby Java 3 10-08-2004 03:01 AM
Appending byte[] to another byte[] array Bharat Bhushan Java 15 08-05-2003 07:52 PM
Chomp temporarily nullifies my scalar variable. Joseph Ellis Perl Misc 14 07-24-2003 11:06 PM



Advertisments