使用复杂类型返回的C#.Net应用程序中的Java Web服务

使用复杂类型返回的C#.Net应用程序中的Java Web服务,c#,web-services,jakarta-ee,soap,complextype,C#,Web Services,Jakarta Ee,Soap,Complextype,我遇到了这个问题: 我已经开发了一个在JavaEE应用程序中公开的WS,这是wsdl:types定义 <wsdl:types> <schema elementFormDefault="qualified" targetNamespace="http://endpoint.ws.solution.client.com" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http:

我遇到了这个问题:
我已经开发了一个在JavaEE应用程序中公开的WS,这是wsdl:types定义

    <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://endpoint.ws.solution.client.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://model.ws.solution.client.com"/>
   <element name="invoke">
    <complexType>
     <sequence>
      <element name="cbte_modo" type="xsd:string"/>
      <element name="cuit_emisor" type="xsd:string"/>
      <element name="pto_vta" type="xsd:int"/>
      <element name="cbte_tipo" type="xsd:int"/>
      <element name="cbte_nro" type="xsd:int"/>
      <element name="cbte_fch" type="xsd:string"/>
      <element name="imp_total" type="xsd:double"/>
      <element name="cod_autorizacion" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>
   <element name="invokeResponse">
    <complexType>
     <sequence>
      <element name="invokeReturn" type="tns1:ComprobanteConstatarResponse"/>
     </sequence>
    </complexType>
   </element>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="http://model.ws.solution.client.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <complexType name="ComprobanteConstatarResponse">
    <sequence>
     <element name="code" nillable="true" type="xsd:string"/>
     <element name="fch_proceso" nillable="true" type="xsd:string"/>
     <element name="msg" nillable="true" type="xsd:string"/>
     <element name="resultado" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
  </schema>
 </wsdl:types>
如您所见,响应是一个名为“compobanteconstatarresponse”的Java类。
此外,我还开发了一个简单的C#控制台应用程序来测试从.NET应用程序调用WS。因此,正如许多教程所说,我已经添加了服务参考,并对调用进行了编码:

 static void Main(string[] args)
        {
            ComprobanteConstatarService webService = new ComprobanteConstatarService();

            ComprobanteConstatarResponse response = new ComprobanteConstatarResponse();
            response = webService.invoke("CAE","20351240181",4001,1,1223,"20140815",100.5,"CAE999999");
            Console.WriteLine("Resultado: " + response.resultado + " - MSG: " + response.msg);
            Console.ReadLine();
        }
调用成功执行,但服务返回包含所有空值的复杂类型(ComprobanteConstatarResponse)。我已经对代码进行了调试,可以看到java应用程序接收到所有参数并正确构建响应,但是当它返回到C#应用程序时,对象具有空值

有什么想法吗?

找到了解决方案

在visual studio中,我转到ComprobanteConstatarResponse定义(在添加服务引用时创建。这将打开Reference.cs文件),并对包含命名空间的XmlTypeAttribute进行了注释:

 /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    //[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://model.ws.solution.client.com")]
    public partial class ComprobanteConstatarResponse {

        private string codeField;

        private string fch_procesoField;

        private string msgField;

        private string resultadoField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public string code {
            get {
                return this.codeField;
            }
            set {
                this.codeField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public string fch_proceso {
            get {
                return this.fch_procesoField;
            }
            set {
                this.fch_procesoField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public string msg {
            get {
                return this.msgField;
            }
            set {
                this.msgField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public string resultado {
            get {
                return this.resultadoField;
            }
            set {
                this.resultadoField = value;
            }
        }
    }
//
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.Xml”,“4.0.30319.33440”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“代码”)]
//[System.Xml.Serialization.XmlTypeAttribute(命名空间=”http://model.ws.solution.client.com")]
公共部分类compobanteconstatarresponse{
私有字符串码域;
私有字符串fch_procesoField;
私有字符串msgField;
私有字符串resultadoField;
/// 
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
公共字符串代码{
得到{
返回此.codeField;
}
设置{
this.codeField=值;
}
}
/// 
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
公共字符串fch_proceso{
得到{
返回此.fch_procesoField;
}
设置{
this.fch_procesoField=值;
}
}
/// 
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
公共字符串消息{
得到{
返回此.msgField;
}
设置{
this.msgField=值;
}
}
/// 
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
公共字符串resultado{
得到{
返回此.resultadoField;
}
设置{
this.resultadoField=值;
}
}
}
然后我再次测试,并填充响应值

 /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    //[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://model.ws.solution.client.com")]
    public partial class ComprobanteConstatarResponse {

        private string codeField;

        private string fch_procesoField;

        private string msgField;

        private string resultadoField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public string code {
            get {
                return this.codeField;
            }
            set {
                this.codeField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public string fch_proceso {
            get {
                return this.fch_procesoField;
            }
            set {
                this.fch_procesoField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public string msg {
            get {
                return this.msgField;
            }
            set {
                this.msgField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public string resultado {
            get {
                return this.resultadoField;
            }
            set {
                this.resultadoField = value;
            }
        }
    }