question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

XmlElement is not honored

See original GitHub issue

XmlElementAttribute is not working on array parameters

Code:

[ServiceContract(Namespace ="urn:test:1")]
public interface ITestService
{
    [OperationContract]
    TestResult ExecuteFunction([XmlElement("parameterArray")]string[] parameterArray);
}

This will parse an empty array.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
MCFHTAGENTScommented, Jun 23, 2019

Hi, I see a new release has just been done (0.0.9.9.6) - that doesn’t seem to address this. Anyway we can get this through?

0reactions
cubidobusinesssolutionscommented, Feb 11, 2021

TL;DR Instead of applying XmlElementAttribute directly to parameters, wrap parameters in request model class:

public interface IService
{
  response action(actionRequest request);
}
[MessageContract]
public class actionRequest
{
  [MessageBodyMember]
  [XmlElement]
  public string param1;
}

Finally, I upgraded to the latest version with only minor issues (see #591). After some digging, I stumbled accross the following comment in Connected Service generated code (namespaces omitted for brevity)

[GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
public interface MyService
{
  // CODEGEN: Parameter 'param1' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'Microsoft.Xml.Serialization.XmlElementAttribute'.
  [OperationContractAttribute(Action="", ReplyAction="*")]
  method1Response method1(method1 request);
}
[DebuggerStepThroughAttribute()]
[GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
[EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[MessageContractAttribute(WrapperName="method1", IsWrapped=true)]
public partial class method1
{
  [MessageBodyMemberAttribute(Order=0)]
  [XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
  public string param1;
}

XmlElementAttribute was never designed to do what I asked for^^

Read more comments on GitHub >

github_iconTop Results From Across the Web

XmlElement(name="custom_name") not working in spring ...
I am almost new to rest services world,here i am trying to change the field name displayed in the output xml. Not sure,am...
Read more >
XmlElement(name="myName") not honored for fields ...
I believe the class hierarchy is not important but I'll include it here anyway. My variable is named isotonicDrink but when e.g. serializing ......
Read more >
Solved: Removing XML Element Not Working - NI Community
Solved: I am loading in an XML file and I need to remove an element. I am using the "Remove Child" method with...
Read more >
XmlElement (Java Platform SE 8 )
A JavaBean property, when annotated with @XmlElement annotation is mapped to a local element in the XML Schema complex type to which the...
Read more >
Guide to JAXB Annotations
When a top-level class or an enum type is annotated with the @XmlRootElement annotation, then its value is represented as XML element in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found