ElementName

Feb 17, 2010 at 5:16 PM

Hi!

Is it possible to add some settings to produce also the element name in the 

XmlElementAttribute ?

I have some problems with the "Order" element and element ordering reading an Oracle Fusion Java WSDL .

Thank you!

Regards,

Camillo

Developer
Feb 18, 2010 at 1:16 PM

Hi Camillo,

The XmlElementAttribute is normally given a value for the ElementName property. Could you please provide more deatil on the problem you are having?

Cheers,

Alex.

Feb 18, 2010 at 1:25 PM
Hi!
Sorry, just to explain better; this is a fragment of the code generated by WSCFblue:
 

/// <remarks/>

public int programId;

/// <remarks/>

[System.Xml.Serialization.

XmlIgnoreAttribute()]

public bool programIdSpecified;

/// <remarks/>

public string productDesc;

/// <remarks/>

[System.Xml.Serialization.

XmlElementAttribute(IsNullable=true)]

public string oneoffSerialFl;

/// <remarks/>

[System.Xml.Serialization.

XmlElementAttribute(IsNullable=true)]

public System.Nullable<int> productionYear;

/// <remarks/>

[System.Xml.Serialization.

XmlIgnoreAttribute()]

public bool productionYearSpecified;

/// <remarks/>

public int originalDuration;

/// <remarks/>

[System.Xml.Serialization.

XmlIgnoreAttribute()]

public bool originalDurationSpecified;

/// <remarks/>

[System.Xml.Serialization.

XmlElementAttribute(IsNullable=true)]

public System.Nullable<int> parentProgramId;

 
Maybe there is something I do not understand; shouldn't it be for example:
 
[System.Xml.Serialization.XmlElementAttribute(ElementName="parentProgramId",IsNullable=true)]
 
in place of:
 
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
 
with the element name specified?
 
Camillo

2010/2/18 alexmeyergleaves <notifications@codeplex.com>

From: alexmeyergleaves

Hi Camillo,

The XmlElementAttribute is normally given a value for the ElementName property. Could you please provide more deatil on the problem you are having?

Cheers,

Alex.

Read the full discussion online.

To add a post to this discussion, reply to this email (WSCFblue@discussions.codeplex.com)

To start a new discussion for this project, email WSCFblue@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Developer
Feb 18, 2010 at 1:46 PM

Hi Camillo,

Thanks for the extra information. If you select the 'Adjust casing' option the ElementName property on the XmlElementAttribute will be set. The field names will be changed to Pascal casing but because the ElementName property is set the serialization should be fine.

Cheers,

Alex.

Feb 18, 2010 at 5:34 PM
Thanks, it works!
Using the proxy I receive this error:
 
System.ServiceModel.CommunicationException was unhandled
  Message="Error in deserializing body of reply message for operation 'GetEditionTitle'."
  Source="mscorlib"
  StackTrace:
    Server stack trace:
       at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, MessagePartDescription returnPart, MessagePartDescriptionCollection bodyParts, Object[] parameters, Boolean isRequest)
       at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
       at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
       at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
       at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at OnAir.IProductPortType.GetEditionTitle(GetEditionTitleRequest request)
       at OnAir.ProductPortTypeClient.OnAir.IProductPortType.GetEditionTitle(GetEditionTitleRequest request) in c:\Resources\Projects\MamOnAir2\Product.cs:line 1880
       at OnAir.ProductPortTypeClient.GetEditionTitle(EditionInput EditionInput) in c:\Resources\Projects\MamOnAir2\Product.cs:line 1887
       at MamOnAir2.Program.Main(String[] args) in c:\Resources\Projects\MamOnAir2\Program.cs:line 20
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.InvalidOperationException
       Message="There is an error in XML document (1, 1020)."
       Source="System.Xml"
       StackTrace:
            at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
            at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
            at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, MessagePartDescription returnPart, MessagePartDescriptionCollection bodyParts, Object[] parameters, Boolean isRequest)
       InnerException: System.FormatException
            Message="Input string was not in a correct format."
            Source="mscorlib"
            StackTrace:
                 at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
                 at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
                 at System.Xml.XmlConvert.ToInt32(String s)
                 at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderIProductPortType.Read4_NullableOfInt32(Boolean checkType)
                 at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderIProductPortType.Read6_ProductType(Boolean isNullable, Boolean checkType)
                 at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderIProductPortType.Read20_EditionTitlesType(Boolean isNullable, Boolean checkType)
                 at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderIProductPortType.Read39_Item()
                 at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer2.Deserialize(XmlSerializationReader reader)
                 at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
            InnerException:
 
It seems that a parameter is not an Int.
Do You know how to understand what parameter is wrong here?
 
Camillo
2010/2/18 alexmeyergleaves <notifications@codeplex.com>

From: alexmeyergleaves

Hi Camillo,

Thanks for the extra information. If you select the 'Adjust casing' option the ElementName property on the XmlElementAttribute will be set. The field names will be changed to Pascal casing but because the ElementName property is set the serialization should be fine.

Cheers,

Alex.

Read the full discussion online.

To add a post to this discussion, reply to this email (WSCFblue@discussions.codeplex.com)

To start a new discussion for this project, email WSCFblue@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Developer
Feb 21, 2010 at 1:05 PM

Are you able to attach your WSDL and XSD files or maybe even a sample project? It certainly seems to have something to do with the value being deserialized for the Nullable<int>.

Feb 22, 2010 at 2:45 PM
Dear Alex,
You are right.
 
If I replace "Nullable<int>" with "string" it seems to work.
 
I noticed that in the body of the SOAP response I have 5 fields specified as "Nullable<int>" which are specified but left with no value:
 
  <ns2:superserieId />
  <ns2:worldId />
  <ns2:channelId />
 
It seems that the XmlSerializer cannot correclty deserialize "Nullable<int>" values.
Do You have any ideas about this?
 
Camillo
 
2010/2/21 alexmeyergleaves <notifications@codeplex.com>

From: alexmeyergleaves

Are you able to attach your WSDL and XSD files or maybe even a sample project? It certainly seems to have something to do with the value being deserialized for the Nullable<int>.

Read the full discussion online.

To add a post to this discussion, reply to this email (WSCFblue@discussions.codeplex.com)

To start a new discussion for this project, email WSCFblue@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Developer
Feb 23, 2010 at 8:30 AM

Hi Camillo,

Can you please post those 5 fields as they appear in your XSD, as well as how they appear in the generated code? If you could also let me know what code generation options you are using that would help me a lot. I don't have enough information at the moment to figure out for you what is actually going wrong.

Cheers,

Alex.

Feb 23, 2010 at 1:24 PM
Here is a sample of the XSD file:

<

xsd:element name="superserieId" type="xsd:int" nillable="true" minOccurs="0"/>

<

xsd:element name="worldId" type="xsd:int" nillable="true" minOccurs="0"/>

<

xsd:element name="channelId" type="xsd:int" nillable="true" minOccurs="0"/>
This is the generated code:

/// <remarks/>

[System.Xml.Serialization.

XmlElementAttribute(IsNullable=true, ElementName="superserieId")]

public System.Nullable<int> SuperserieId;

/// <remarks/>

[System.Xml.Serialization.

XmlIgnoreAttribute()]

public bool SuperserieIdSpecified;

/// <remarks/>

[System.Xml.Serialization.

XmlElementAttribute(IsNullable=true, ElementName="worldId")]

public System.Nullable<int> WorldId;

/// <remarks/>

[System.Xml.Serialization.

XmlIgnoreAttribute()]

public bool WorldIdSpecified;

/// <remarks/>

[System.Xml.Serialization.

XmlElementAttribute(IsNullable=true, ElementName="channelId")]

public System.Nullable<int> ChannelId;

/// <remarks/>

[System.Xml.Serialization.

XmlIgnoreAttribute()]

public bool ChannelIdSpecified;
Attached the screenshot of the WSCF plugin configurations.
 
It seems that when an empty element is generated in the soap response, the soap deserializer ignores the "Nullable" word and tries anyway to convert it to int.
 
Please, tell me if You need more info.
 
Thank you!
Regards,
Camillo
2010/2/23 alexmeyergleaves <notifications@codeplex.com>

From: alexmeyergleaves

Hi Camillo,

Can you please post those 5 fields as they appear in your XSD, as well as how they appear in the generated code? If you could also let me know what code generation options you are using that would help me a lot. I don't have enough information at the moment to figure out for you what is actually going wrong.

Cheers,

Alex.

Read the full discussion online.

To add a post to this discussion, reply to this email (WSCFblue@discussions.codeplex.com)

To start a new discussion for this project, email WSCFblue@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Developer
Feb 23, 2010 at 2:25 PM

Hi Camillo,

You should not have empty elements being returned in the response. An empty element does not translate into null because your property is Nullable.

If an element that is defined as nillable="true" in your schema, is present in the XML without a value, it should indicate this using the xsi:nil="true" attribute.

Example XSD:

<xsd:element name="channelId" type="xsd:int" minOccurs="0" nillable="true" />

Example XML:

<channelId xsi:nil="true"></channelId>

I would take a closer look at the contract the service is implementing and make sure the server does not return these empty elements. Because of the minOccurs="0" in your schema it would also be fine if the element was simply not present.

Cheers,

Alex.

Feb 23, 2010 at 2:35 PM
Because the web service I am trying to connect is made in Java, I found this doc that seems to certify the presence of empty elements:
“Element that is nillable, meaning that the element CAN BE EMPTY without causing a validation error. For each of the XML schema built-in types that map to a Java primitive, there is a corresponding Java primitive wrapper that can be used if a nillable="true" attribute is specified.”
 
And this is from MSDN:
nillable

The indicator of whether an explicit nil value can be assigned to the element. This applies to element content and not the attributes of the element. The default is false.

If nillable is true, this enables an instance of the element to have the nil attribute set to true. The nil attribute is defined as part of the XML Schema namespace for instances.

For example, the following fragment defines a single element with nillable set to true.

<xs:element name="myDate" type="xs:date" nillable="true"/>

The following fragment uses that element and has an explicit nil value (nil attribute set to true).

<myDate xsi:nil="true"></myDate>


2010/2/23 alexmeyergleaves <notifications@codeplex.com>

From: alexmeyergleaves

Hi Camillo,

You should not have empty elements being returned in the response. An empty element does not translate into null because your property is Nullable.

If an element that is defined as nillable="true" in your schema, is present in the XML without a value, it should indicate this using the xsi:nil="true" attribute.

Example XSD:

<xsd:element name="channelId" type="xsd:int" minOccurs="0" nillable="true" />

Example XML:

<channelId xsi:nil="true"></channelId>

I would take a closer look at the contract the service is implementing and make sure the server does not return these empty elements. Because of the minOccurs="0" in your schema it would also be fine if the element was simply not present.

Cheers,

Alex.

Read the full discussion online.

To add a post to this discussion, reply to this email (WSCFblue@discussions.codeplex.com)

To start a new discussion for this project, email WSCFblue@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com