4

We have exposed a SOAP web service in Java that includes complex types. One of the types includes a member that is of type ENUM. This ENUM is exposed in the WSDL.

When adding a service reference in C# to this web service, the Reference.cs ends up showing the ENUM as

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://services.war.indi.ecm.barmergek.de/")]
public enum status {

    /// <remarks/>
    UNBEKANNT,

    /// <remarks/>
    WERT_OK,

    /// <remarks/>
    FALSCH,

    /// <remarks/>
    RICHTIG,

    /// <remarks/>
    IRRELEVANT,
}

Receiving values from the Java web service with those values works just fine.

Now when we use this ENUM in C# as a value to the respective type member, it will not be serialized when calling a web service method with this value. The XML element simply does not exist.

What are we missing?

EDIT: This is the part of the WSDL that defines the status ENUM

<xs:simpleType name="status">
 <xs:restriction base="xs:string">
  <xs:enumeration value="UNBEKANNT" /> 
  <xs:enumeration value="WERT_OK" /> 
  <xs:enumeration value="FALSCH" /> 
  <xs:enumeration value="RICHTIG" /> 
  <xs:enumeration value="IRRELEVANT" /> 
 </xs:restriction>
</xs:simpleType>

It is part of the complex type indexField

<xs:complexType name="indexField">
 <xs:sequence>
  <xs:element name="fieldId" type="xs:int" /> 
  <xs:element minOccurs="0" name="fieldName" type="xs:string" /> 
  <xs:element minOccurs="0" name="fieldValue" type="xs:string" /> 
  <xs:element minOccurs="0" name="status" type="tns:status" /> 
 </xs:sequence>
</xs:complexType>

In C# we fill the value from the status ENUM

idxField.status = status.IRRELEVANT;

We verified in a debug session that the enum value is set in the resulting parameter object for the web service method before calling it. But the resulting SOAP message does not contain this value

<indexFields>
 <fieldId>0</fieldId>
 <fieldName>ordnungsbegriff</fieldName>
 <fieldValue>93685377</fieldValue>
</indexFields>

EDIT2: We have exposed another method in the same web service which requires only one parameter of type status. And when we invoke that method, the status parameter is correctly serialized.

Bottom line: The status enum will not be serialized correctly if used inside a complex type .... if it is used directly on parameter level for the web method, it serializes correctly

devnull69
  • 16,402
  • 8
  • 50
  • 61

2 Answers2

1

now .net SOAP client generated classes have some additional properties(Boolean) as "...Specified" relevant to complex fields. where u can set(true) to serialize;

more: XmlSerializer, "Specified" suffix and IReflect

kdaShivantha
  • 337
  • 5
  • 10
0

A non-optimal solution was:

We made status non-optional via JAXB annotation, so the minOccurs="0" disappeared from the WSDL. After that we were able to successfully transfer the serialized status value from C#, even if it was a subtype.

devnull69
  • 16,402
  • 8
  • 50
  • 61