2009-12-17 28 views
6

我一直在尝试几天,以便使.NET客户端能够充分使用我的基于Coldfusion的Web服务器提供的web应用程序。我本身并不是一个.NET开发人员,但我碰巧拥有一份VS 2003的副本,这看起来应该可以做到。从.NET调用基于AXIS的Web服务时,嵌套的复杂类型元素永远不会被填充

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

这里是由ColdFusion的生成WSDL:

<?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服务存根:

//------------------------------------------------------------------------------ 
// <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应用程序,测试服务:

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总是“undef根据调试器的不同,可以得到一个“值”。打印输出如下:

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,并没有区别。我试过返回一个真正的自定义数据库与两个属性,而不是我的临时关联数组,而且工作正常,但重写我的API以避免关联数组目前不是一个真正的选择。这个API可以在ColdFusion,PHP/NuSOAP和Ruby on Rails上正常工作,所以它似乎也应该可以让它与.NET一起工作。

我希望有人能提供一些见解。我怀疑这里存在某种名称空间问题,但我不清楚SOAP和XML是否足够清楚它是什么。我也在网上疯狂搜索解决方案,但我还没有找到解决此问题的单个人,这非常令人沮丧!

请求:

POST /remote_api/pfapi/v/trunk/remote_io_test.cfc HTTP/1.1 
VsDebuggerCausalityData: [snip] 
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 1.1.4322.2443) 
Content-Type: text/xml; charset=utf-8 
SOAPAction: "" 
Content-Length: 488 
Expect: 100-continue 
Host: leon.cupahr.tafkan.nooch 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://trunk.v.pfapi.remote_api" xmlns:types="http://trunk.v.pfapi.remote_api/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
    <tns:get_struct /> 
    </soap:Body> 
</soap:Envelope> 

响应:

HTTP/1.1 200 OK 
Date: Thu, 17 Dec 2009 15:14:33 GMT 
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.7l DAV/2 PHP/5.2.8 JRun/4.0 Phusion_Passenger/2.2.7 
Set-Cookie: CFID=21543;expires=Sat, 10-Dec-2039 15:14:33 GMT;path=/ 
Set-Cookie: CFTOKEN=479cc311ca4875db-9D346355-ED36-6183-C8895635E4EE1252;expires=Sat, 10-Dec-2039 15:14:33 GMT;path=/ 
Transfer-Encoding: chunked 
Content-Type: text/xml; charset=utf-8 

<?xml version="1.0" encoding="utf-8"?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<soapenv:Body> 
    <ns1:get_structResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://trunk.v.pfapi.remote_api"> 
    <get_structReturn xsi:type="ns2:Map" xmlns:ns2="http://xml.apache.org/xml-soap"> 
    <item xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> 
    <key xsi:type="soapenc:string">FOO</key> 
    <value xsi:type="soapenc:string">bar</value> 
    </item> 
    <item> 
    <key xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">ANOTHERKEY</key> 
    <value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">another value</value> 
    </item> 
    </get_structReturn> 
    </ns1:get_structResponse> 
</soapenv:Body> 
</soapenv:Envelope> 

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

  • 使用WCF而不是ASMX
  • 使用.NET 3.5
  • 使用VB.NET与Web服务,而不是C#

沟通,他送我的服务引用设置对话框的“数据类型”部分的截屏。是否有可能更改集合类型和Dictionary集合类型的设置可以解决此问题?

更新2:这里是remote_io_test的ColdFusion代码。CFC

<cfcomponent name="remote_io_test" 
    hint="This is a collection of test methods to allow remote developers 
     to evaluate datatype support, etc in their programming environment."> 

<cffunction name="get_struct" returntype="struct" access="remote" output="no" 
     hint="Returns an associative array with two keys, 'foo' and 'anotherKey'. 
      Allows you to test your implementation's support for WDDX encoding. 
      ColdFusion and PHP (w/ NuSOAP) will automatically decode the result 
      into an associative array. Feedback on other languages is appreciated."> 
    <cfset var stFoo = structNew()> 
    <cfset stFoo.foo = "bar"> 
    <cfset stFoo.anotherKey = "another value"> 
    <cfreturn duplicate(stFoo)> 
</cffunction> <!--- get_struct ---> 


<cffunction name="multiplier" returntype="numeric" access="remote" output="no" 
     hint="Multiplies two factors and returns the result. Allows you to test 
      passing simple variables to a remote method."> 
    <cfargument name="factor1" type="numeric" required="yes"> 
    <cfargument name="factor2" type="numeric" required="yes"> 

    <cfreturn factor1 * factor2> 
</cffunction> <!--- multiplier ---> 


<cffunction name="struct_keycount" returntype="numeric" access="remote" output="no" 
     hint="Returns the number of keys in an upload associative array. Allows 
      you to test passing complex variables to a remote method."> 
    <cfargument name="theStruct" type="struct" required="yes"> 

    <cfreturn structCount(theStruct)> 
</cffunction> <!--- struct_keycount ---> 

感谢您的阅读,并在此先感谢您的答复!在link text

+0

有你,如果确定这是服务器还是客户端问题? (是否有任何其他软件客户端成功调用get_struct()?) – 2009-12-17 22:45:02

+0

您可以添加一个简单的ColdFusion代码示例,您的.net应用程序正在进行测试,因此我们中的一些人可以对其进行测试吗? – kevink 2009-12-18 06:42:32

+0

@Dan Sorensen,谢谢你的提问。我有Coldfusion,PHP和Ruby on Rails客户端在我的真实API中成功发送和接收结构。这个Web服务用于人们开始使用API​​时的互操作性测试。 – sbleon 2009-12-18 19:30:33

回答

1

答案是:不要在您的web服务中使用Coldfusion结构。

与我们之前的其他人一样,我们放弃并重写了我们的API,以便在请求或响应中不使用任何关联数组。我们现在使用从CFC自动创建的标量,数组和复杂类型。这一次,我们用PHP,Ruby,Coldfusion,Java和.NET测试了我们的概念验证,以确保它实际上可以互操作。

现在,静态类型语言无法以任何明智的方式处理完全任意的远程数据类型,这是很有意义的。

感谢您的反馈!

2

交叉贴我一直在这个项目我从事物的.NET客户端挣扎 - 我试图消耗写在ColdFusion的Web服务。从我发现的文档中,ColdFusion中的结构数据类型不会直接映射到任何Web服务类型,并且在我看来这是Axis的一个缺陷。

您可能已经阅读了与我尝试解决此问题时所用的网页相同的内容,但似乎如果要使用ColdFusion创建Web服务,建议不要使用结构类型。如果你的网络服务还没有生效,并且你可以使用不同的东西,我会建议走这条路。我尝试从ColdFusion中返回对象,它可以从.NET客户端正常工作。

我真的放弃了这个问题,并为我的.NET程序写了一个自定义的客户端,它只会读取由ColdFusion Web服务返回的Xml并将其转换为字典,因为我对服务没有影响试图打电话。

我在测试过程中发现的一件事 - 我尝试调用的服务是在ColdFusion的旧版本上运行(我相信7)。每当我调用该服务时,.NET客户端都会返回null。我在自己的机器上安装了ColdFusion,并编写了一个简单的服务,并发现.NET客户端返回了一个Map类型的对象(它来自WSDL),但Map对象的属性全部为空。

我很想看看克里斯哈斯的建议在你的问题设置dotNetSoapEncFix的问题解决问题。

+0

谢谢,理查德。我在看我的选择。我想我将不得不为我的API使用基于字符串的格式(XML或JSON)。任何涉及复杂数据类型的解决方案只是在试图弥合松散/强类型语言鸿沟时寻求麻烦。 – sbleon 2009-12-23 14:34:33

+0

看看Axis 1.2文档,他们似乎说不要使用哈希表(即CF结构),尤其是与.net http://ws.apache.org/axis/java/user-guide.html#WhatAxisCanSendViaSOAPWithRestrictedInteroperability – Leigh 2009-12-23 16:27:34

0

还有就是你的问题的解决方案,它是在这里:

http://ws-i.org/Profiles/BasicProfile-2.0-2010-11-09.html#soapenc_Array

http://ws-i.org/Profiles/BasicProfile-1.2-2010-11-09.html#soapenc_Array

您的问题奠定了这里是准确的:

<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> 

只是重新定义的类型,如这个:

<element name="ArrayOf_xsd_string" type="tns:OnlyStringArrayType"/> 
<complexType name="OnlyStringArrayType"> 
    <sequence> 
    <element name="array_element" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/> 
    </sequence> 
</complexType> 
<element name="ArrayOfArrayOf_xsd_anyType" type="tns:AnyTypeArrayType"/> 
<complexType name="AnyTypeArrayType"> 
    <sequence> 
    <element name="array_element" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/> 
    </sequence> 
</complexType> 

由于元素名称的原因,它仍然不完全符合上面提到的WS-I配置文件,但它应该很容易由客户端和类文件生成器来处理。

我写了这个解决方案为别人谁也偶然发现了这个问题:)

顺便说WSDL和SOAP是在一个....一个很大的痛苦;)

+0

Pawel,谢谢为答复。我认为这是实际上给我带来问题的“地图”类型。字符串数组对我来说并不是真正的解决方案,因为我需要发送嵌套的复杂数据。无论如何,我们的.NET客户端现在正在使用我们较新的API版本,它预先使用了关联区域。 – sbleon 2011-06-13 17:27:16

相关问题