在调用基于AXIS的Web服务时,永远不会填充嵌套的复杂类型元素 [英] Nested complex-type elements never get populated when calling AXIS-based web service

查看:56
本文介绍了在调用基于AXIS的Web服务时,永远不会填充嵌套的复杂类型元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了几天让.NET客户端完全使用基于Coldfusion的Web应用程序提供的Web服务器。我本身不是.NET开发人员,但我碰巧有一个VS 2003的副本,这似乎应该可以解决这个问题。

我可以使用简单的multiplier()方法我的Web服务需要两个数字并返回一个数字,所以简单的类型工作正常。这是复杂的类型,正在杀死我。我基本上试图从一个名为get_struct()的方法返回一个关联数组。我得到一个类型为Map的对象,但属性(称为item),它应该是一个带有两个元素(类型为mapItem)的数组,总是有一个"未定义的值"。

这里是由ColdFusion生成的WSDL:

I've been trying for a couple of days now to get a .NET client working fully with a Web Server provided by my Coldfusion-based web app. I'm not a .NET developer, per se, but I happen to have a copy of VS 2003, which seems like it should do the trick.

I can use a simple multiplier() method in my web service that takes two numbers and returns a number, so simple types are working fine. It's the complex types that are killing me. I'm basically trying to return an associative array from a method called get_struct(). I get an object of type Map back, but the property (called item), which is supposed to be an array with two elements (of type mapItem) always has an "undefined value".

Here's the WSDL that is generated by ColdFusion:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://trunk.v.pfapi.remote_api" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://trunk.v.pfapi.remote_api" xmlns:intf="http://trunk.v.pfapi.remote_api" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://rpc.xml.coldfusion" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Macromedia ColdFusion MX version 7,0,2,142559-->
 <wsdl:types>
  <schema targetNamespace="http://rpc.xml.coldfusion" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://trunk.v.pfapi.remote_api"/>
   <import namespace="http://xml.apache.org/xml-soap"/>
   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
   <complexType name="CFCInvocationException">
    <sequence/>
   </complexType>
   <complexType name="QueryBean">
    <sequence>
     <element name="columnList" nillable="true" type="impl:ArrayOf_xsd_string"/>
     <element name="data" nillable="true" type="impl:ArrayOfArrayOf_xsd_anyType"/>
    </sequence>
   </complexType>
  </schema>
  <schema targetNamespace="http://xml.apache.org/xml-soap" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://trunk.v.pfapi.remote_api"/>
   <import namespace="http://rpc.xml.coldfusion"/>
   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
   <complexType name="mapItem">
    <sequence>
     <element name="key" nillable="true" type="xsd:anyType"/>
     <element name="value" nillable="true" type="xsd:anyType"/>
    </sequence>
   </complexType>
   <complexType name="Map">
    <sequence>
     <element maxOccurs="unbounded" minOccurs="0" name="item" type="apachesoap:mapItem"/>
    </sequence>
   </complexType>
  </schema>
  <schema targetNamespace="http://trunk.v.pfapi.remote_api" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://rpc.xml.coldfusion"/>
   <import namespace="http://xml.apache.org/xml-soap"/>
   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
   <complexType name="ArrayOf_xsd_string">
    <complexContent>
     <restriction base="soapenc:Array">
      <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
     </restriction>
    </complexContent>
   </complexType>
   <complexType name="ArrayOfArrayOf_xsd_anyType">
    <complexContent>
     <restriction base="soapenc:Array">
      <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:anyType[][]"/>
     </restriction>
    </complexContent>
   </complexType>
  </schema>
 </wsdl:types>
   <wsdl:message name="CFCInvocationException">
      <wsdl:part name="fault" type="tns1:CFCInvocationException"/>
   </wsdl:message>
   <wsdl:message name="multiplierResponse">
      <wsdl:part name="multiplierReturn" type="xsd:double"/>
   </wsdl:message>
   <wsdl:message name="get_structResponse">
      <wsdl:part name="get_structReturn" type="apachesoap:Map"/>
   </wsdl:message>
   <wsdl:message name="struct_keycountResponse">
      <wsdl:part name="struct_keycountReturn" type="xsd:double"/>
   </wsdl:message>
   <wsdl:message name="get_structRequest">
   </wsdl:message>
   <wsdl:message name="multiplierRequest">
      <wsdl:part name="factor1" type="xsd:double"/>
      <wsdl:part name="factor2" type="xsd:double"/>   </wsdl:message>
   <wsdl:message name="struct_keycountRequest">
      <wsdl:part name="theStruct" type="apachesoap:Map"/>
   </wsdl:message>
   <wsdl:portType name="remote_io_test">
      <wsdl:operation name="multiplier" parameterOrder="factor1 factor2">
         <wsdl:input message="impl:multiplierRequest" name="multiplierRequest"/>
         <wsdl:output message="impl:multiplierResponse" name="multiplierResponse"/>
         <wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/>
      </wsdl:operation>
      <wsdl:operation name="get_struct">
         <wsdl:input message="impl:get_structRequest" name="get_structRequest"/>
         <wsdl:output message="impl:get_structResponse" name="get_structResponse"/>
         <wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/>
      </wsdl:operation>
      <wsdl:operation name="struct_keycount" parameterOrder="theStruct">
         <wsdl:input message="impl:struct_keycountRequest" name="struct_keycountRequest"/>
         <wsdl:output message="impl:struct_keycountResponse" name="struct_keycountResponse"/>
         <wsdl:fault message="impl:CFCInvocationException" name="CFCInvocationException"/>
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="remote_io_test.cfcSoapBinding" type="impl:remote_io_test">
      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="multiplier">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="multiplierRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://trunk.v.pfapi.remote_api" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="multiplierResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://trunk.v.pfapi.remote_api" use="encoded"/>
         </wsdl:output>
         <wsdl:fault name="CFCInvocationException">
            <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="CFCInvocationException" namespace="http://trunk.v.pfapi.remote_api" use="encoded"/>
         </wsdl:fault>
      </wsdl:operation>
      <wsdl:operation name="get_struct">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="get_structRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://trunk.v.pfapi.remote_api" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="get_structResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://trunk.v.pfapi.remote_api" use="encoded"/>
         </wsdl:output>
         <wsdl:fault name="CFCInvocationException">
            <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="CFCInvocationException" namespace="http://trunk.v.pfapi.remote_api" use="encoded"/>
         </wsdl:fault>
      </wsdl:operation>
      <wsdl:operation name="struct_keycount">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="struct_keycountRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://trunk.v.pfapi.remote_api" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="struct_keycountResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://trunk.v.pfapi.remote_api" use="encoded"/>
         </wsdl:output>
         <wsdl:fault name="CFCInvocationException">
            <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="CFCInvocationException" namespace="http://trunk.v.pfapi.remote_api" use="encoded"/>
         </wsdl:fault>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="remote_io_testService">
  <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
This is a collection of test methods to allow remote developers
			to evaluate datatype support, etc in their programming environment.
			The WSDL endpoint for this web service is [YOUR PEERFOCUS SITE]/remote_api/pfapi/v/trunk/remote_io_test.cfc?wsdl  </wsdl:documentation>
      <wsdl:port binding="impl:remote_io_test.cfcSoapBinding" name="remote_io_test.cfc">
         <wsdlsoap:address location="http://leon.cupahr.tafkan.localhost/remote_api/pfapi/v/trunk/remote_io_test.cfc"/>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>




这里是我在VS中添加Web引用时生成的Web服务存根:

 

and here's the web service stub generated when I add a web reference in VS:

//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.1.4322.2443
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

// 
// This source code was auto-generated by Microsoft.VSDesigner, Version 1.1.4322.2443.
// 
namespace pfapi_test.remote_io_test {
    using System.Diagnostics;
    using System.Xml.Serialization;
    using System;
    using System.Web.Services.Protocols;
    using System.ComponentModel;
    using System.Web.Services;
    
    
    /// <remarks/>
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="remote_io_test.cfcSoapBinding", Namespace="http://trunk.v.pfapi.remote_api")]
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(QueryBean))]
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(CFCInvocationException))]
    public class remote_io_testService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        /// <remarks/>
        public remote_io_testService() {
            this.Url = "http://leon.cupahr.tafkan.nooch/remote_api/pfapi/v/trunk/remote_io_test.cfc";
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://trunk.v.pfapi.remote_api", ResponseNamespace="http://trunk.v.pfapi.remote_api")]
        [return: System.Xml.Serialization.SoapElementAttribute("multiplierReturn")]
        public System.Double multiplier(System.Double factor1, System.Double factor2) {
            object[] results = this.Invoke("multiplier", new object[] {
                        factor1,
                        factor2});
            return ((System.Double)(results[0]));
        }
        
        /// <remarks/>
        public System.IAsyncResult Beginmultiplier(System.Double factor1, System.Double factor2, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("multiplier", new object[] {
                        factor1,
                        factor2}, callback, asyncState);
        }
        
        /// <remarks/>
        public System.Double Endmultiplier(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((System.Double)(results[0]));
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://trunk.v.pfapi.remote_api", ResponseNamespace="http://trunk.v.pfapi.remote_api")]
        [return: System.Xml.Serialization.SoapElementAttribute("get_structReturn")]
        public Map get_struct() {
            object[] results = this.Invoke("get_struct", new object[0]);
            return ((Map)(results[0]));
        }
        
        /// <remarks/>
        public System.IAsyncResult Beginget_struct(System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("get_struct", new object[0], callback, asyncState);
        }
        
        /// <remarks/>
        public Map Endget_struct(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((Map)(results[0]));
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://trunk.v.pfapi.remote_api", ResponseNamespace="http://trunk.v.pfapi.remote_api")]
        [return: System.Xml.Serialization.SoapElementAttribute("struct_keycountReturn")]
        public System.Double struct_keycount(Map theStruct) {
            object[] results = this.Invoke("struct_keycount", new object[] {
                        theStruct});
            return ((System.Double)(results[0]));
        }
        
        /// <remarks/>
        public System.IAsyncResult Beginstruct_keycount(Map theStruct, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("struct_keycount", new object[] {
                        theStruct}, callback, asyncState);
        }
        
        /// <remarks/>
        public System.Double Endstruct_keycount(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((System.Double)(results[0]));
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.SoapTypeAttribute("Map", "http://xml.apache.org/xml-soap")]
    public class Map {
        
        /// <remarks/>
        public mapItem[] item;
    }
    
    /// <remarks/>
    [System.Xml.Serialization.SoapTypeAttribute("mapItem", "http://xml.apache.org/xml-soap")]
    public class mapItem {
        
        /// <remarks/>
        public object key;
        
        /// <remarks/>
        public object value;
    }
    
    /// <remarks/>
    [System.Xml.Serialization.SoapTypeAttribute("QueryBean", "http://rpc.xml.coldfusion")]
    public class QueryBean {
        
        /// <remarks/>
        public string[] columnList;
        
        /// <remarks/>
        public object[] data;
    }
    
    /// <remarks/>
    [System.Xml.Serialization.SoapTypeAttribute("CFCInvocationException", "http://rpc.xml.coldfusion")]
    public class CFCInvocationException {
    }
}




最后,我的CLI应用程序测试服务:



And finally, my CLI app that tests the service:

using System;

namespace pfapi_test
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			//
			// TODO: Add code to start application here
			//

			Console.WriteLine("Instantiating WS");

			remote_io_test.remote_io_testService testWS = new remote_io_test.remote_io_testService();

			Console.WriteLine("Calling multiplier(3,15)");
			Console.WriteLine(testWS.multiplier(3,15));
			
			Console.WriteLine("Calling get_struct()");
			remote_io_test.Map theStruct = testWS.get_struct();
			Console.Write("result: ");
			Console.WriteLine(theStruct);
			Console.Write("result.item: ");
			Console.WriteLine(theStruct.item);

			Console.WriteLine("Press Enter to exit...");
			Console.ReadLine();
		}
	}
}




无论我尝试什么,theStruct.item始终是"未定义的值"。根据调试器。打印输出如下所示:



No matter what I try, theStruct.item is always "undefined value" according to the debugger. The printed output looks like:

Instantiating WS
Calling multiplier(3,15)
45
Calling get_struct()
result: pfapi_test.remote_io_test.Map
result.item:
Press Enter to exit...



我尝试过使用ColdFusion 8,没有区别。我已经尝试使用两个属性而不是我的ad-hoc关联数组返回一个真正的自定义数据库,并且工作正常,但是重写我的API以避免关联数组目前不是一个真正的选项。 API可以与ColdFusion,PHP / NuSOAP和Ruby on Rails一起使用,因此看起来应该可以使用.NET。(
我希望有人可以提供一些见解。我怀疑这里存在某种命名空间问题,但我不太了解SOAP和XML,无法弄清楚它是什么。我也疯狂搜索在线解决方案,但我找不到一个人解决了这个问题,这非常令人沮丧!

感谢您的阅读,并提前感谢您的回复!


I've tried using ColdFusion 8, and there's no difference. I've tried returning a real custom database with two properties instead of my ad-hoc associative array, and that works fine, but rewriting my API to avoid associative arrays isn't really an option at this time. The API works fine with ColdFusion, PHP/NuSOAP, and Ruby on Rails, so it seems like it should be possible to get it working with .NET as well.

I hope someone can provide some insight. I have the suspicion that there's some kind of namespace issue here, but I don't know SOAP and XML well enough to figure out what it is. I've also searched like mad for a solution online, but I haven't found a single person who's solved this problem, which is very disheartening!

Thanks for reading, and thanks in advance for your replies!

推荐答案

更新:我从另一端的.NET开发人员那里听到了,他尝试了以下所有方面都无济于事:


  • 使用WCF代替ASMX

  • 使用.NET 3.5

  • 使用VB.NET与Web服务进行通信而不是C#

Update: I heard from the .NET developer on the other end, and he's tried all of the following to no avail:
  • using WCF instead of ASMX
  • using .NET 3.5
  • using VB.NET to communicate with the web service instead of C#


这篇关于在调用基于AXIS的Web服务时,永远不会填充嵌套的复杂类型元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆