Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 30397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:26:29+00:00 2026-05-10T13:26:29+00:00

Help! I have an Axis web service that is being consumed by a C#

  • 0

Help! I have an Axis web service that is being consumed by a C# application. Everything works great, except that arrays of long values always come across as [0,0,0,0] – the right length, but the values aren’t deserialized. I have tried with other primitives (ints, doubles) and the same thing happens. What do I do? I don’t want to change the semantics of my service.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T13:26:29+00:00Added an answer on May 10, 2026 at 1:26 pm

    Here’s what I ended up with. I have never found another solution out there for this, so if you have something better, by all means, contribute.

    First, the long array definition in the wsdl:types area:

      <xsd:complexType name='ArrayOf_xsd_long'>     <xsd:complexContent mixed='false'>       <xsd:restriction base='soapenc:Array'>         <xsd:attribute wsdl:arrayType='soapenc:long[]' ref='soapenc:arrayType' />       </xsd:restriction>     </xsd:complexContent>   </xsd:complexType> 

    Next, we create a SoapExtensionAttribute that will perform the fix. It seems that the problem was that .NET wasn’t following the multiref id to the element containing the double value. So, we process the array item, go find the value, and then insert it the value into the element:

    [AttributeUsage(AttributeTargets.Method)] public class LongArrayHelperAttribute : SoapExtensionAttribute {     private int priority = 0;      public override Type ExtensionType     {         get { return typeof (LongArrayHelper); }     }      public override int Priority     {         get { return priority; }         set { priority = value; }     } }  public class LongArrayHelper : SoapExtension {     private static ILog log = LogManager.GetLogger(typeof (LongArrayHelper));      public override object GetInitializer(LogicalMethodInfo methodInfo, SoapExtensionAttribute attribute)     {         return null;     }      public override object GetInitializer(Type serviceType)     {         return null;     }      public override void Initialize(object initializer)     {     }      private Stream originalStream;      private Stream newStream;      public override void ProcessMessage(SoapMessage m)     {         switch (m.Stage)         {             case SoapMessageStage.AfterSerialize:                 newStream.Position = 0; //need to reset stream                  CopyStream(newStream, originalStream);                 break;              case SoapMessageStage.BeforeDeserialize:                 XmlWriterSettings settings = new XmlWriterSettings();                 settings.Indent = false;                 settings.NewLineOnAttributes = false;                 settings.NewLineHandling = NewLineHandling.None;                 settings.NewLineChars = '';                 XmlWriter writer = XmlWriter.Create(newStream, settings);                  XmlDocument xmlDocument = new XmlDocument();                 xmlDocument.Load(originalStream);                  List<XmlElement> longArrayItems = new List<XmlElement>();                 Dictionary<string, XmlElement> multiRefs = new Dictionary<string, XmlElement>();                 FindImportantNodes(xmlDocument.DocumentElement, longArrayItems, multiRefs);                 FixLongArrays(longArrayItems, multiRefs);                  xmlDocument.Save(writer);                 newStream.Position = 0;                 break;         }     }      private static void FindImportantNodes(XmlElement element, List<XmlElement> longArrayItems,                                            Dictionary<string, XmlElement> multiRefs)     {         string val = element.GetAttribute('soapenc:arrayType');         if (val != null && val.Contains(':long['))         {             longArrayItems.Add(element);         }         if (element.Name == 'multiRef')         {             multiRefs[element.GetAttribute('id')] = element;         }         foreach (XmlNode node in element.ChildNodes)         {             XmlElement child = node as XmlElement;             if (child != null)             {                 FindImportantNodes(child, longArrayItems, multiRefs);             }         }     }      private static void FixLongArrays(List<XmlElement> longArrayItems, Dictionary<string, XmlElement> multiRefs)     {         foreach (XmlElement element in longArrayItems)         {             foreach (XmlNode node in element.ChildNodes)             {                 XmlElement child = node as XmlElement;                 if (child != null)                 {                     string href = child.GetAttribute('href');                     if (href == null || href.Length == 0)                     {                         continue;                     }                     if (href.StartsWith('#'))                     {                         href = href.Remove(0, 1);                     }                     XmlElement multiRef = multiRefs[href];                     if (multiRef == null)                     {                         continue;                     }                     child.RemoveAttribute('href');                     child.InnerXml = multiRef.InnerXml;                     if (log.IsDebugEnabled)                     {                         log.Debug('Replaced multiRef id '' + href + '' with value: ' + multiRef.InnerXml);                     }                 }             }         }     }      public override Stream ChainStream(Stream s)     {         originalStream = s;         newStream = new MemoryStream();         return newStream;     }      private static void CopyStream(Stream from, Stream to)     {         TextReader reader = new StreamReader(from);         TextWriter writer = new StreamWriter(to);         writer.WriteLine(reader.ReadToEnd());         writer.Flush();     } } 

    Finally, we tag all methods in the Reference.cs file that will be deserializing a long array with our attribute:

        [SoapRpcMethod('', RequestNamespace='http://some.service.provider',         ResponseNamespace='http://some.service.provider')]     [return : SoapElement('getFooReturn')]     [LongArrayHelper]     public Foo getFoo()     {         object[] results = Invoke('getFoo', new object[0]);         return ((Foo) (results[0]));     } 

    This fix is long-specific, but it could probably be generalized to handle any primitive type having this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a live search on my help page that searches our help database
I have a little dilemma that maybe you can help me sort out. I've
I have a regex call that I need help with. I haven't posted my
I have an MFC legacy app that I help to maintain. I'm not quite
We're having a small issue and could use some help - we have the
I'm still working with this huge list of URLs, all the help I have
I have heard using PDB files can help diagnose where a crash occurred. My
Help! I have a PHP (PHP 5.2.5) script on HOST1 trying to connect to
I have a series of Extension methods to help with null-checking on IDataRecord objects,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.