.NET bug: Error reflecting complex object with Nul
Hi -
I have a problem calling a web service to retrieve a complex object which has Nullable<DateTime> properties on it. As soon as I try to instantiate an object of the proxy type generated by WSDL.exe - as soon as the constructor is touched - the following error is thrown.
There was an error reflecting 'BIRTHDAYResult'. 'date' is an invalid value for the SoapElementAttribute.DataType property. The property may only be specified for primitive types.
(full exception text below)
All I have done is generate the proxy class using WSDL.exe and attempt to instantiate it.
The web service is a Lotus Notes web service, and it works fine when tested from the Eclipse web service tester, so this appears to be a .NET problem.
I am using .NET 2.0 and have the latest System.Xml assembly.
I have several webservices I need to call with this problem - the example below is a simple one written to research the problem.
I have copied in the following details below:
⢠Full exception and stack trace
⢠WSDL
⢠Proxy class generated by WSDL.exe
⢠LotusScript definition of the BIRTHDAY class which is being returned
The Exception Thrown:
System.InvalidOperationException: Method DateTestProxy.BIRTHDAY can not be reflected. ---> System.InvalidOperationException: There was an error reflecting 'BIRTHDAYResult'. ---> System.InvalidOperationException: 'date' is an invalid value for the SoapElementAttribute.DataType property. The property may only be specified for primitive types.
at System.Xml.Serialization.SoapReflectionImporter.Im portTypeMapping(TypeModel model, String dataType)
at System.Xml.Serialization.SoapReflectionImporter.Im portAccessorMapping(MemberMapping accessor, FieldModel model, SoapAttributes a, String ns, XmlSchemaForm form)
at System.Xml.Serialization.SoapReflectionImporter.Im portFieldMapping(FieldModel model, SoapAttributes a, String ns)
at System.Xml.Serialization.SoapReflectionImporter.Im portStructLikeMapping(StructModel model)
at System.Xml.Serialization.SoapReflectionImporter.Im portTypeMapping(TypeModel model, String dataType)
at System.Xml.Serialization.SoapReflectionImporter.Im portAccessorMapping(MemberMapping accessor, FieldModel model, SoapAttributes a, String ns, XmlSchemaForm form)
at System.Xml.Serialization.SoapReflectionImporter.Im portMemberMapping(XmlReflectionMember xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers, XmlSchemaForm form)
at System.Xml.Serialization.SoapReflectionImporter.Im portMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean writeAccessors, Boolean validateWrapperElement)
--- End of inner exception stack trace ---
at System.Xml.Serialization.SoapReflectionImporter.Im portMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean writeAccessors, Boolean validateWrapperElement)
at System.Xml.Serialization.SoapReflectionImporter.Im portMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean writeAccessors, Boolean validate, XmlMappingAccess access)
at System.Web.Services.Protocols.SoapReflector.Import MembersMapping(XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, Boolean serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use, SoapParameterStyle paramStyle, String elementName, String elementNamespace, Boolean nsIsDefault, XmlReflectionMember[] members, Boolean validate, Boolean openModel, String key, Boolean writeAccess)
at System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, String defaultNs)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapReflector.Reflec tMethod(LogicalMethodInfo methodInfo, Boolean client, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, String defaultNs)
at System.Web.Services.Protocols.SoapClientType.Gener ateXmlMappings(Type type, ArrayList soapMethodList, String serviceNamespace, Boolean serviceDefaultIsEncoded, ArrayList mappings)
at System.Web.Services.Protocols.SoapClientType..ctor (Type type)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol..ctor()
at Agims.Implementation.Reporting.DateTestProxy..ctor () in C:\Dev\_svn\FPM\trunk\Agims\Agims.Implementation\R eporting\DateTestProxy.cs:line 37
at Agims.UserInterface.Forms.Reporting.NotesArchiveMa intForm.btnTest_Click(Object sender, EventArgs e) in C:\Dev\_svn\FPM\trunk\Agims\Agims.Interface\Forms\ Reporting\NotesArchiveMaintForm.cs:line 189
The WSDL definition for the service:
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="urn:DefaultNamespace" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:DefaultNamespace" xmlns:intf="urn:DefaultNamespace" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <wsdl:types>
- <schema targetNamespace="urn:DefaultNamespace" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="BIRTHDAY">
- <sequence>
<element name="BORN" nillable="true" type="xsd:date" />
<element name="NAME" type="xsd:string" />
</sequence>
</complexType>
</schema>
</wsdl:types>
- <wsdl:message name="PRINTDATETIMERequest">
<wsdl:part name="TESTDATETIME" type="xsd:dateTime" />
</wsdl:message>
- <wsdl:message name="PRINTDATEResponse">
<wsdl:part name="PRINTDATEReturn" type="xsd:date" />
</wsdl:message>
- <wsdl:message name="PRINTDATERequest">
<wsdl:part name="TESTDATETIME" type="xsd:date" />
</wsdl:message>
- <wsdl:message name="BIRTHDAYRequest">
<wsdl:part name="TESTDATETIME" type="xsd:date" />
</wsdl:message>
- <wsdl:message name="PRINTDATETIMEResponse">
<wsdl:part name="PRINTDATETIMEReturn" type="xsd:dateTime" />
</wsdl:message>
- <wsdl:message name="BIRTHDAYResponse">
<wsdl:part name="BIRTHDAYReturn" type="impl:BIRTHDAY" />
</wsdl:message>
- <wsdl:portType name="busytime">
- <wsdl:operation name="BIRTHDAY" parameterOrder="TESTDATETIME">
<wsdl:input message="impl:BIRTHDAYRequest" name="BIRTHDAYRequest" />
<wsdl:output message="impl:BIRTHDAYResponse" name="BIRTHDAYResponse" />
</wsdl:operation>
- <wsdl:operation name="PRINTDATETIME" parameterOrder="TESTDATETIME">
<wsdl:input message="impl:PRINTDATETIMERequest" name="PRINTDATETIMERequest" />
<wsdl:output message="impl:PRINTDATETIMEResponse" name="PRINTDATETIMEResponse" />
</wsdl:operation>
- <wsdl:operation name="PRINTDATE" parameterOrder="TESTDATETIME">
<wsdl:input message="impl:PRINTDATERequest" name="PRINTDATERequest" />
<wsdl:output message="impl:PRINTDATEResponse" name="PRINTDATEResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="DominoSoapBinding" type="impl:busytime">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="BIRTHDAY">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="BIRTHDAYRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:DefaultNamespace" use="encoded" />
</wsdl:input>
- <wsdl:output name="BIRTHDAYResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:DefaultNamespace" use="encoded" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="PRINTDATETIME">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="PRINTDATETIMERequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:DefaultNamespace" use="encoded" />
</wsdl:input>
- <wsdl:output name="PRINTDATETIMEResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:DefaultNamespace" use="encoded" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="PRINTDATE">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="PRINTDATERequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:DefaultNamespace" use="encoded" />
</wsdl:input>
- <wsdl:output name="PRINTDATEResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:DefaultNamespace" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="busytimeService">
- <wsdl:port binding="impl:DominoSoapBinding" name="Domino">
<wsdlsoap:address location="http://smtpserver2:80/agws.nsf/WSDates?OpenWebService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The proxy class generated by WSDL.exe
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.832
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
//
// This source code was auto-generated by wsdl, Version=2.0.50727.42.
//
namespace Agims.Implementation.Reporting {
using System.Diagnostics;
using System.Web.Services;
using System.ComponentModel;
using System.Web.Services.Protocols;
using System;
using System.Xml.Serialization;
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("ws dl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="DominoSoapBinding", Namespace="urn:DefaultNamespace")]
public partial class busytimeService : System.Web.Services.Protocols.SoapHttpClientProtoc ol {
private System.Threading.SendOrPostCallback PRINTDATETIMEOperationCompleted;
private System.Threading.SendOrPostCallback PRINTDATEOperationCompleted;
private System.Threading.SendOrPostCallback BIRTHDAYOperationCompleted;
/// <remarks/>
public busytimeService() {
this.Url = "http://smtpserver2:80/agws.nsf/WSDates?OpenWebService";
}
/// <remarks/>
public event PRINTDATETIMECompletedEventHandler PRINTDATETIMECompleted;
/// <remarks/>
public event PRINTDATECompletedEventHandler PRINTDATECompleted;
/// <remarks/>
public event BIRTHDAYCompletedEventHandler BIRTHDAYCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("", RequestNamespace="urn:DefaultNamespace", ResponseNamespace="urn:DefaultNamespace")]
[return: System.Xml.Serialization.SoapElementAttribute("PRI NTDATETIMEReturn")]
public System.DateTime PRINTDATETIME(System.DateTime TESTDATETIME) {
object[] results = this.Invoke("PRINTDATETIME", new object[] {
TESTDATETIME});
return ((System.DateTime)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginPRINTDATETIME(System.DateTime TESTDATETIME, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("PRINTDATETIME", new object[] {
TESTDATETIME}, callback, asyncState);
}
/// <remarks/>
public System.DateTime EndPRINTDATETIME(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((System.DateTime)(results[0]));
}
/// <remarks/>
public void PRINTDATETIMEAsync(System.DateTime TESTDATETIME) {
this.PRINTDATETIMEAsync(TESTDATETIME, null);
}
/// <remarks/>
public void PRINTDATETIMEAsync(System.DateTime TESTDATETIME, object userState) {
if ((this.PRINTDATETIMEOperationCompleted == null)) {
this.PRINTDATETIMEOperationCompleted = new System.Threading.SendOrPostCallback(this.OnPRINTDA TETIMEOperationCompleted);
}
this.InvokeAsync("PRINTDATETIME", new object[] {
TESTDATETIME}, this.PRINTDATETIMEOperationCompleted, userState);
}
private void OnPRINTDATETIMEOperationCompleted(object arg) {
if ((this.PRINTDATETIMECompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEvent Args invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));
this.PRINTDATETIMECompleted(this, new PRINTDATETIMECompletedEventArgs(invokeArgs.Results , invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("", RequestNamespace="urn:DefaultNamespace", ResponseNamespace="urn:DefaultNamespace")]
[return: System.Xml.Serialization.SoapElementAttribute("PRI NTDATEReturn", DataType="date")]
public System.DateTime PRINTDATE([System.Xml.Serialization.SoapElementAttribute(Data Type="date")] System.DateTime TESTDATETIME) {
object[] results = this.Invoke("PRINTDATE", new object[] {
TESTDATETIME});
return ((System.DateTime)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginPRINTDATE(System.DateTime TESTDATETIME, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("PRINTDATE", new object[] {
TESTDATETIME}, callback, asyncState);
}
/// <remarks/>
public System.DateTime EndPRINTDATE(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((System.DateTime)(results[0]));
}
/// <remarks/>
public void PRINTDATEAsync(System.DateTime TESTDATETIME) {
this.PRINTDATEAsync(TESTDATETIME, null);
}
/// <remarks/>
public void PRINTDATEAsync(System.DateTime TESTDATETIME, object userState) {
if ((this.PRINTDATEOperationCompleted == null)) {
this.PRINTDATEOperationCompleted = new System.Threading.SendOrPostCallback(this.OnPRINTDA TEOperationCompleted);
}
this.InvokeAsync("PRINTDATE", new object[] {
TESTDATETIME}, this.PRINTDATEOperationCompleted, userState);
}
private void OnPRINTDATEOperationCompleted(object arg) {
if ((this.PRINTDATECompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEvent Args invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));
this.PRINTDATECompleted(this, new PRINTDATECompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapRpcMethodAttribu te("", RequestNamespace="urn:DefaultNamespace", ResponseNamespace="urn:DefaultNamespace")]
[return: System.Xml.Serialization.SoapElementAttribute("BIR THDAYReturn")]
public BIRTHDAY BIRTHDAY([System.Xml.Serialization.SoapElementAttribute(Data Type="date")] System.DateTime TESTDATETIME) {
object[] results = this.Invoke("BIRTHDAY", new object[] {
TESTDATETIME});
return ((BIRTHDAY)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginBIRTHDAY(System.DateTime TESTDATETIME, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("BIRTHDAY", new object[] {
TESTDATETIME}, callback, asyncState);
}
/// <remarks/>
public BIRTHDAY EndBIRTHDAY(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((BIRTHDAY)(results[0]));
}
/// <remarks/>
public void BIRTHDAYAsync(System.DateTime TESTDATETIME) {
this.BIRTHDAYAsync(TESTDATETIME, null);
}
/// <remarks/>
public void BIRTHDAYAsync(System.DateTime TESTDATETIME, object userState) {
if ((this.BIRTHDAYOperationCompleted == null)) {
this.BIRTHDAYOperationCompleted = new System.Threading.SendOrPostCallback(this.OnBIRTHDA YOperationCompleted);
}
this.InvokeAsync("BIRTHDAY", new object[] {
TESTDATETIME}, this.BIRTHDAYOperationCompleted, userState);
}
private void OnBIRTHDAYOperationCompleted(object arg) {
if ((this.BIRTHDAYCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEvent Args invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEve ntArgs)(arg));
this.BIRTHDAYCompleted(this, new BIRTHDAYCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("ws dl", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.SoapTypeAttribute(Namespa ce="urn:DefaultNamespace")]
public partial class BIRTHDAY {
private System.Nullable<System.DateTime> bORNField;
/// <remarks/>
[System.Xml.Serialization.SoapElementAttribute(Data Type="date", IsNullable=true)]
public System.Nullable<System.DateTime> BORN {
get {
return this.bORNField;
}
set {
this.bORNField = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("ws dl", "2.0.50727.42")]
public delegate void PRINTDATETIMECompletedEventHandler(object sender, PRINTDATETIMECompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("ws dl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
public partial class PRINTDATETIMECompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal PRINTDATETIMECompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
/// <remarks/>
public System.DateTime Result {
get {
this.RaiseExceptionIfNecessary();
return ((System.DateTime)(this.results[0]));
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("ws dl", "2.0.50727.42")]
public delegate void PRINTDATECompletedEventHandler(object sender, PRINTDATECompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("ws dl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
public partial class PRINTDATECompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal PRINTDATECompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
/// <remarks/>
public System.DateTime Result {
get {
this.RaiseExceptionIfNecessary();
return ((System.DateTime)(this.results[0]));
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("ws dl", "2.0.50727.42")]
public delegate void BIRTHDAYCompletedEventHandler(object sender, BIRTHDAYCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("ws dl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
public partial class BIRTHDAYCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
internal BIRTHDAYCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
/// <remarks/>
public BIRTHDAY Result {
get {
this.RaiseExceptionIfNecessary();
return ((BIRTHDAY)(this.results[0]));
}
}
}
}
BIRTHDAY class definition - LotusScript
Class Birthday
Public born As XSD_DATE
Sub new()
Set born = New XSD_DATE
End Sub
End Class
|