Web 引用调用返回带有 null 字段的对象

发布于 2025-01-06 18:49:15 字数 30169 浏览 5 评论 0原文

我知道这是一个重复出现的问题。但我在过去两天用谷歌搜索,但仍然找不到我的问题的解决方案。流行的答案与名称空间相关,但它仍然对我没有帮助。

好的,所以我的 wsdl 是:

<?xml version="1.0" encoding="UTF-8"?>
<!-- WSDL for http://daac.ornl.gov/cgi-bin/MODIS/GLBVIZ_1_Glb_subset/MODIS_webservice.pl created by Pod::WSDL version: 0.04 on Mon May 24 15:41:43 2010 -->
<wsdl:definitions targetNamespace="http://daac.ornl.gov/MODIS_webservice" 
              xmlns:impl="http://daac.ornl.gov/MODIS_webservice" 
              xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
              xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
              xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
              xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
              xmlns:tns1="http://daac.ornl.gov/MODIS_webservice">

<wsdl:types>
    <schema targetNamespace="http://daac.ornl.gov/MODIS_webservice" xmlns="http://www.w3.org/2001/XMLSchema">
        <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
        <complexType name="ArrayOfString">
            <complexContent>
                <restriction base="soapenc:Array">
                    <attribute ref="soapenc:arrayType" wsdl:arrayType="soapenc:string[]" />
                </restriction>
            </complexContent>
        </complexType>
        <complexType name="ModisData">
            <sequence>
                <element name="xllcorner" nillable="true" type="xsd:float">
                    <annotation>
                        <documentation>
                        X-Longitude of the corner of lower left pixel in Sinusoidal projection
                        </documentation>
                    </annotation>
                </element>
                <element name="yllcorner" nillable="true" type="xsd:float">
                    <annotation>
                <documentation>
                Y-Latitude of the corner of lower left pixel in Sinusoidal projection
                </documentation>
                    </annotation>
                </element>
                <element name="cellsize" nillable="true" type="xsd:float">
                    <annotation>
                <documentation>Resolution of the data</documentation>
                    </annotation>
                </element>
                <element name="nrows" nillable="true" type="xsd:float">
                    <annotation>
                <documentation>Number of rows</documentation>
                    </annotation>
                </element>
                <element name="ncols" nillable="true" type="xsd:float">
                    <annotation>
                <documentation>Number of rows</documentation>
                    </annotation>
                </element>
                <element name="band" nillable="true" type="xsd:string">
                    <annotation>
                        <documentation>Band Name</documentation>
                    </annotation>
                </element>
                <element name="units" nillable="true" type="xsd:string">
                    <annotation>
                        <documentation>Units for the band</documentation>
                    </annotation>
                </element>
                <element name="scale" nillable="true" type="xsd:float">
                    <annotation>
                        <documentation>scale of the data values</documentation>
                    </annotation>
                </element>
                <element name="latitude" nillable="true" type="xsd:float">
                    <annotation>
                        <documentation>Latitude in degrees of the subset location</documentation>
                    </annotation>
                </element>
                <element name="longitude" nillable="true" type="xsd:float">
                    <annotation>
                        <documentation>Longitude in degrees of the subset location</documentation>
                    </annotation>
                </element>
                <element name="header" nillable="true" type="xsd:string">
                    <annotation>
                        <documentation>Header for the Subset returned</documentation>
                    </annotation>
                </element>
                <element name="subset" nillable="true" type="tns1:ArrayOfString">
                    <annotation>
                        <documentation>Subset data</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </schema>
</wsdl:types>

<wsdl:message name="getproductsRequest">
</wsdl:message>

<wsdl:message name="getproductsResponse">
    <wsdl:part name="getproductsReturn" type="tns1:ArrayOfString">
        <wsdl:documentation>This returns the list of products available. Product shortname is used.</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getbandsRequest">
    <wsdl:part name="Product" type="xsd:string">
        <wsdl:documentation>MODIS Product Shortname</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getbandsResponse">
    <wsdl:part name="getbandsReturn" type="tns1:ArrayOfString">
        <wsdl:documentation>This returns the list of bands available for a product</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getdatesRequest">
    <wsdl:part name="Latitude" type="xsd:float">
        <wsdl:documentation>Latitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Longitude" type="xsd:float">
        <wsdl:documentation>Longitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Product" type="xsd:string">
        <wsdl:documentation>MODIS Product Shortname</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getdatesResponse">
    <wsdl:part name="getdatesReturn" type="tns1:ArrayOfString">
        <wsdl:documentation>This returns the list of composite dates available for the product,Latitude,Longitude combination</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getsubsetRequest">
    <wsdl:part name="Latitude" type="xsd:float">
        <wsdl:documentation>Latitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Longitude" type="xsd:float">
        <wsdl:documentation>Longitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Product" type="xsd:string">
        <wsdl:documentation>MODIS Product Shortname</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Band" type="xsd:string">
        <wsdl:documentation>Enter the band you want to retreive. Enter all to get all bands.</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="MODIS_Subset_Start_Date" type="xsd:string">
        <wsdl:documentation>MODIS Composite Date Start of the Subset period</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="MODIS_Subset_End_Date" type="xsd:string">
        <wsdl:documentation>MODIS Composite Date End of the Subset period</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Km_Above_Below" type="xsd:string">
        <wsdl:documentation>Size in km of the subset above and below the center location</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Km_Left_Right" type="xsd:string">
        <wsdl:documentation>Size in km of the subset left and right the center location</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getsubsetResponse">
    <wsdl:part name="getsubsetReturn" type="tns1:ModisData">
        <wsdl:documentation>This returns the subset for the location,product and date combination and detailed projection information.</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getsubsetorderRequest">
    <wsdl:part name="Latitude" type="xsd:float">
        <wsdl:documentation>Latitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Longitude" type="xsd:float">
        <wsdl:documentation>Longitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Product" type="xsd:string">
        <wsdl:documentation>MODIS Product Shortname</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Email" type="xsd:string">
        <wsdl:documentation>Enter the email address to which you want to receive the order</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="UID" type="xsd:string">
        <wsdl:documentation>Unique tag for the order</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="MODIS_Subset_Start_Date" type="xsd:string">
        <wsdl:documentation>MODIS Composite Date Start of the Subset period</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="MODIS_Subset_End_Date" type="xsd:string">
        <wsdl:documentation>MODIS Composite Date End of the Subset period</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Km_Above_Below" type="xsd:string">
        <wsdl:documentation>Size in km of the subset above and below the center location</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Km_Left_Right" type="xsd:string">
        <wsdl:documentation>Size in km of the subset left and right the center location</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getsubsetorderResponse">
    <wsdl:part name="getsubsetorderReturn" type="xsd:string">
        <wsdl:documentation>This returns the order ID for the subset ID. An email with a link to the subset order would be dispatched to the email address provided.</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:portType name="myServiceHandler">
    <wsdl:operation name="getproducts" parameterOrder="">
        <wsdl:input message="impl:getproductsRequest" name="getproductsRequest" />
        <wsdl:output message="impl:getproductsResponse" name="getproductsResponse" />
    </wsdl:operation>

    <wsdl:operation name="getbands" parameterOrder="Product">
        <wsdl:input message="impl:getbandsRequest" name="getbandsRequest" />
        <wsdl:output message="impl:getbandsResponse" name="getbandsResponse" />
    </wsdl:operation>

    <wsdl:operation name="getdates" parameterOrder="Latitude Longitude Product">
        <wsdl:input message="impl:getdatesRequest" name="getdatesRequest" />
        <wsdl:output message="impl:getdatesResponse" name="getdatesResponse" />
    </wsdl:operation>

    <wsdl:operation name="getsubset" parameterOrder="Latitude Longitude Product Band MODIS_Subset_Start_Date MODIS_Subset_End_Date Km_Above_Below Km_Left_Right">
        <wsdl:input message="impl:getsubsetRequest" name="getsubsetRequest" />
        <wsdl:output message="impl:getsubsetResponse" name="getsubsetResponse" />
    </wsdl:operation>

    <wsdl:operation name="getsubsetorder" parameterOrder="Latitude Longitude Product Email UID MODIS_Subset_Start_Date MODIS_Subset_End_Date Km_Above_Below Km_Left_Right">
        <wsdl:input message="impl:getsubsetorderRequest" name="getsubsetorderRequest" />
        <wsdl:output message="impl:getsubsetorderResponse" name="getsubsetorderResponse" />
    </wsdl:operation>

</wsdl:portType>

<wsdl:binding name="myServiceSoapBinding" type="impl:myServiceHandler">
    <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />

    <wsdl:operation name="getproducts">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="getproductsRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:input>
        <wsdl:output name="getproductsResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="getbands">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="getbandsRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:input>
        <wsdl:output name="getbandsResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="getdates">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="getdatesRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:input>
        <wsdl:output name="getdatesResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="getsubset">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="getsubsetRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:input>
        <wsdl:output name="getsubsetResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="getsubsetorder">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="getsubsetorderRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:input>
        <wsdl:output name="getsubsetorderResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:output>
    </wsdl:operation>

</wsdl:binding>

<wsdl:service name="myServiceHandlerService">
    <wsdl:port binding="impl:myServiceSoapBinding" name="myService">
        <wsdlsoap:address location="http://daac.ornl.gov/cgi-bin/MODIS/GLBVIZ_1_Glb_subset/MODIS_webservice.pl" />
    </wsdl:port>
</wsdl:service>

</wsdl:definitions>

我生成的代理类是:

namespace FarmNet.Modis {
// .... I cut off code
[System.Web.Services.WebServiceBindingAttribute(Name="myServiceSoapBinding", Namespace="http://daac.ornl.gov/MODIS_webservice")]
public partial class myServiceHandlerService : System.Web.Services.Protocols.SoapHttpClientProtocol {

   // ........... code cut off
    /// <remarks/>
    public myServiceHandlerService() {

    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://daac.ornl.gov/MODIS_webservice", ResponseNamespace="http://daac.ornl.gov/MODIS_webservice")]
    [return: System.Xml.Serialization.SoapElementAttribute("getproductsReturn")]
    public string[] getproducts() {
        object[] results = this.Invoke("getproducts", new object[0]);
        return ((string[])(results[0]));
    }

    /// <remarks/>
    public void getproductsAsync() {
        this.getproductsAsync(null);
    }

    /// <remarks/>
    public void getproductsAsync(object userState) {
        if ((this.getproductsOperationCompleted == null)) {
            this.getproductsOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetproductsOperationCompleted);
        }
        this.InvokeAsync("getproducts", new object[0], this.getproductsOperationCompleted, userState);
    }

    private void OngetproductsOperationCompleted(object arg) {
        if ((this.getproductsCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getproductsCompleted(this, new getproductsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://daac.ornl.gov/MODIS_webservice", ResponseNamespace="http://daac.ornl.gov/MODIS_webservice")]
    [return: System.Xml.Serialization.SoapElementAttribute("getbandsReturn")]
    public string[] getbands(string Product) {
        object[] results = this.Invoke("getbands", new object[] {
                    Product});
        return ((string[])(results[0]));
    }

    /// <remarks/>
    public void getbandsAsync(string Product) {
        this.getbandsAsync(Product, null);
    }

    /// <remarks/>
    public void getbandsAsync(string Product, object userState) {
        if ((this.getbandsOperationCompleted == null)) {
            this.getbandsOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetbandsOperationCompleted);
        }
        this.InvokeAsync("getbands", new object[] {
                    Product}, this.getbandsOperationCompleted, userState);
    }

    private void OngetbandsOperationCompleted(object arg) {
        if ((this.getbandsCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getbandsCompleted(this, new getbandsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://daac.ornl.gov/MODIS_webservice", ResponseNamespace="http://daac.ornl.gov/MODIS_webservice")]
    [return: System.Xml.Serialization.SoapElementAttribute("getdatesReturn")]
    public string[] getdates(float Latitude, float Longitude, string Product) {
        object[] results = this.Invoke("getdates", new object[] {
                    Latitude,
                    Longitude,
                    Product});
        return ((string[])(results[0]));
    }

    /// <remarks/>
    public void getdatesAsync(float Latitude, float Longitude, string Product) {
        this.getdatesAsync(Latitude, Longitude, Product, null);
    }

    /// <remarks/>
    public void getdatesAsync(float Latitude, float Longitude, string Product, object userState) {
        if ((this.getdatesOperationCompleted == null)) {
            this.getdatesOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetdatesOperationCompleted);
        }
        this.InvokeAsync("getdates", new object[] {
                    Latitude,
                    Longitude,
                    Product}, this.getdatesOperationCompleted, userState);
    }

    private void OngetdatesOperationCompleted(object arg) {
        if ((this.getdatesCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getdatesCompleted(this, new getdatesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://daac.ornl.gov/MODIS_webservice", ResponseNamespace="http://daac.ornl.gov/MODIS_webservice")]
    [return: System.Xml.Serialization.SoapElementAttribute("getsubsetReturn")]
    public ModisData getsubset(float Latitude, float Longitude, string Product, string Band, string MODIS_Subset_Start_Date, string MODIS_Subset_End_Date, string Km_Above_Below, string Km_Left_Right) {
        object[] results = this.Invoke("getsubset", new object[] {
                    Latitude,
                    Longitude,
                    Product,
                    Band,
                    MODIS_Subset_Start_Date,
                    MODIS_Subset_End_Date,
                    Km_Above_Below,
                    Km_Left_Right});
        return ((ModisData)(results[0]));
    }

    /// <remarks/>
    public void getsubsetAsync(float Latitude, float Longitude, string Product, string Band, string MODIS_Subset_Start_Date, string MODIS_Subset_End_Date, string Km_Above_Below, string Km_Left_Right) {
        this.getsubsetAsync(Latitude, Longitude, Product, Band, MODIS_Subset_Start_Date, MODIS_Subset_End_Date, Km_Above_Below, Km_Left_Right, null);
    }

    /// <remarks/>
    public void getsubsetAsync(float Latitude, float Longitude, string Product, string Band, string MODIS_Subset_Start_Date, string MODIS_Subset_End_Date, string Km_Above_Below, string Km_Left_Right, object userState) {
        if ((this.getsubsetOperationCompleted == null)) {
            this.getsubsetOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetsubsetOperationCompleted);
        }
        this.InvokeAsync("getsubset", new object[] {
                    Latitude,
                    Longitude,
                    Product,
                    Band,
                    MODIS_Subset_Start_Date,
                    MODIS_Subset_End_Date,
                    Km_Above_Below,
                    Km_Left_Right}, this.getsubsetOperationCompleted, userState);
    }

    private void OngetsubsetOperationCompleted(object arg) {
        if ((this.getsubsetCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getsubsetCompleted(this, new getsubsetCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

   // Code is cut off
[System.Xml.Serialization.SoapTypeAttribute(Namespace="http://daac.ornl.gov/MODIS_webservice")]
public partial class ModisData {

    private System.Nullable<float> xllcornerField;

    private System.Nullable<float> yllcornerField;

    private System.Nullable<float> cellsizeField;

    private System.Nullable<float> nrowsField;

    private System.Nullable<float> ncolsField;

    private string bandField;

    private string unitsField;

    private System.Nullable<float> scaleField;

    private System.Nullable<float> latitudeField;

    private System.Nullable<float> longitudeField;

    private string headerField;

    private string[] subsetField;

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> xllcorner {
        get {
            return this.xllcornerField;
        }
        set {
            this.xllcornerField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> yllcorner {
        get {
            return this.yllcornerField;
        }
        set {
            this.yllcornerField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> cellsize {
        get {
            return this.cellsizeField;
        }
        set {
            this.cellsizeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> nrows {
        get {
            return this.nrowsField;
        }
        set {
            this.nrowsField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> ncols {
        get {
            return this.ncolsField;
        }
        set {
            this.ncolsField = value;
        }
    }

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

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

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> scale {
        get {
            return this.scaleField;
        }
        set {
            this.scaleField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> latitude {
        get {
            return this.latitudeField;
        }
        set {
            this.latitudeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> longitude {
        get {
            return this.longitudeField;
        }
        set {
            this.longitudeField = value;
        }
    }

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

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public string[] subset {
        get {
            return this.subsetField;
        }
        set {
            this.subsetField = value;
        }
    }
 // Code is cut off
}

现在所有函数:getproducts()getdates()getbands()都工作正常。唯一不起作用的函数是getsubset()。我使用 Fiddler 并看到正确接收到的肥皂响应为:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns1="http://daac.ornl.gov/MODIS_webservice">
    <soap:Body>
        <getsubsetResponse xmlns="http://daac.ornl.gov/MODIS_webservice">
            <tns1:getsubsetReturn xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="tns1:ModisData">
                <xllcorner xsi:type="xsd:float">12900942.51</xllcorner>
                <yllcorner xsi:type="xsd:float">-3785264.93</yllcorner>
                <cellsize xsi:type="xsd:float">463.312716528</cellsize>
                <nrows xsi:type="xsd:float">21</nrows>
                <ncols xsi:type="xsd:float">21</ncols>
                <band xsi:type="xsd:string">LC_Property_1</band>
                <units xsi:type="xsd:string">Not Available</units>
                <scale xsi:type="xsd:float">0</scale>
                <latitude xsi:type="xsd:float">-34</latitude>
                <longitude xsi:type="xsd:float">140</longitude>
                <header xsi:type="xsd:string">HDFname,...     </header>
                <subset soapenc:arrayType="xsd:string[1]" xsi:type="soapenc:Array">
                    <item xsi:type="xsd:string">MCD12Q1.A2001001....</item>
                </subset>
            </tns1:getsubsetReturn>
        </getsubsetResponse>
    </soap:Body>
</soap:Envelope>

我的代码隐藏,我在其中调用 Web 服务:

myServiceHandlerClient o = new myServiceHandlerClient();
// This WORKS:
string[] products = o.getproducts();
// This does NOT work, data is returned with all null fields:
ModisData data = o.getsubset(-34, 140, "MCD12Q1", "LC_Property_1", "A2001001", "A2001001", "5", "5");

好的,所以根据我的研究,命名空间中可能存在不匹配,但我找不到它。 wsdl 文件中的命名空间和肥皂响应中的命名空间是相同的(这就是所有其他函数工作的原因)。另外,我也没有看到元素名称有任何拼写错误或任何错误。

这里可能出了什么问题?请帮忙。

ps:我什至尝试通过添加来自 Visual Studio 的服务引用来生成代理类来使用 WCF。然而,这些函数都不起作用,它们都返回 null。

I know this is a repeated problem. But I've Googled in the last 2 days, but still can not find the solution to my issue. The popular answer is namespace related but it still does not help me.

Ok, so my wsdl is:

<?xml version="1.0" encoding="UTF-8"?>
<!-- WSDL for http://daac.ornl.gov/cgi-bin/MODIS/GLBVIZ_1_Glb_subset/MODIS_webservice.pl created by Pod::WSDL version: 0.04 on Mon May 24 15:41:43 2010 -->
<wsdl:definitions targetNamespace="http://daac.ornl.gov/MODIS_webservice" 
              xmlns:impl="http://daac.ornl.gov/MODIS_webservice" 
              xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
              xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
              xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
              xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
              xmlns:tns1="http://daac.ornl.gov/MODIS_webservice">

<wsdl:types>
    <schema targetNamespace="http://daac.ornl.gov/MODIS_webservice" xmlns="http://www.w3.org/2001/XMLSchema">
        <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
        <complexType name="ArrayOfString">
            <complexContent>
                <restriction base="soapenc:Array">
                    <attribute ref="soapenc:arrayType" wsdl:arrayType="soapenc:string[]" />
                </restriction>
            </complexContent>
        </complexType>
        <complexType name="ModisData">
            <sequence>
                <element name="xllcorner" nillable="true" type="xsd:float">
                    <annotation>
                        <documentation>
                        X-Longitude of the corner of lower left pixel in Sinusoidal projection
                        </documentation>
                    </annotation>
                </element>
                <element name="yllcorner" nillable="true" type="xsd:float">
                    <annotation>
                <documentation>
                Y-Latitude of the corner of lower left pixel in Sinusoidal projection
                </documentation>
                    </annotation>
                </element>
                <element name="cellsize" nillable="true" type="xsd:float">
                    <annotation>
                <documentation>Resolution of the data</documentation>
                    </annotation>
                </element>
                <element name="nrows" nillable="true" type="xsd:float">
                    <annotation>
                <documentation>Number of rows</documentation>
                    </annotation>
                </element>
                <element name="ncols" nillable="true" type="xsd:float">
                    <annotation>
                <documentation>Number of rows</documentation>
                    </annotation>
                </element>
                <element name="band" nillable="true" type="xsd:string">
                    <annotation>
                        <documentation>Band Name</documentation>
                    </annotation>
                </element>
                <element name="units" nillable="true" type="xsd:string">
                    <annotation>
                        <documentation>Units for the band</documentation>
                    </annotation>
                </element>
                <element name="scale" nillable="true" type="xsd:float">
                    <annotation>
                        <documentation>scale of the data values</documentation>
                    </annotation>
                </element>
                <element name="latitude" nillable="true" type="xsd:float">
                    <annotation>
                        <documentation>Latitude in degrees of the subset location</documentation>
                    </annotation>
                </element>
                <element name="longitude" nillable="true" type="xsd:float">
                    <annotation>
                        <documentation>Longitude in degrees of the subset location</documentation>
                    </annotation>
                </element>
                <element name="header" nillable="true" type="xsd:string">
                    <annotation>
                        <documentation>Header for the Subset returned</documentation>
                    </annotation>
                </element>
                <element name="subset" nillable="true" type="tns1:ArrayOfString">
                    <annotation>
                        <documentation>Subset data</documentation>
                    </annotation>
                </element>
            </sequence>
        </complexType>
    </schema>
</wsdl:types>

<wsdl:message name="getproductsRequest">
</wsdl:message>

<wsdl:message name="getproductsResponse">
    <wsdl:part name="getproductsReturn" type="tns1:ArrayOfString">
        <wsdl:documentation>This returns the list of products available. Product shortname is used.</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getbandsRequest">
    <wsdl:part name="Product" type="xsd:string">
        <wsdl:documentation>MODIS Product Shortname</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getbandsResponse">
    <wsdl:part name="getbandsReturn" type="tns1:ArrayOfString">
        <wsdl:documentation>This returns the list of bands available for a product</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getdatesRequest">
    <wsdl:part name="Latitude" type="xsd:float">
        <wsdl:documentation>Latitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Longitude" type="xsd:float">
        <wsdl:documentation>Longitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Product" type="xsd:string">
        <wsdl:documentation>MODIS Product Shortname</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getdatesResponse">
    <wsdl:part name="getdatesReturn" type="tns1:ArrayOfString">
        <wsdl:documentation>This returns the list of composite dates available for the product,Latitude,Longitude combination</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getsubsetRequest">
    <wsdl:part name="Latitude" type="xsd:float">
        <wsdl:documentation>Latitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Longitude" type="xsd:float">
        <wsdl:documentation>Longitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Product" type="xsd:string">
        <wsdl:documentation>MODIS Product Shortname</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Band" type="xsd:string">
        <wsdl:documentation>Enter the band you want to retreive. Enter all to get all bands.</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="MODIS_Subset_Start_Date" type="xsd:string">
        <wsdl:documentation>MODIS Composite Date Start of the Subset period</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="MODIS_Subset_End_Date" type="xsd:string">
        <wsdl:documentation>MODIS Composite Date End of the Subset period</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Km_Above_Below" type="xsd:string">
        <wsdl:documentation>Size in km of the subset above and below the center location</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Km_Left_Right" type="xsd:string">
        <wsdl:documentation>Size in km of the subset left and right the center location</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getsubsetResponse">
    <wsdl:part name="getsubsetReturn" type="tns1:ModisData">
        <wsdl:documentation>This returns the subset for the location,product and date combination and detailed projection information.</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getsubsetorderRequest">
    <wsdl:part name="Latitude" type="xsd:float">
        <wsdl:documentation>Latitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Longitude" type="xsd:float">
        <wsdl:documentation>Longitude in geographic Lat/Long WGS 84 coordinate system</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Product" type="xsd:string">
        <wsdl:documentation>MODIS Product Shortname</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Email" type="xsd:string">
        <wsdl:documentation>Enter the email address to which you want to receive the order</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="UID" type="xsd:string">
        <wsdl:documentation>Unique tag for the order</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="MODIS_Subset_Start_Date" type="xsd:string">
        <wsdl:documentation>MODIS Composite Date Start of the Subset period</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="MODIS_Subset_End_Date" type="xsd:string">
        <wsdl:documentation>MODIS Composite Date End of the Subset period</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Km_Above_Below" type="xsd:string">
        <wsdl:documentation>Size in km of the subset above and below the center location</wsdl:documentation>
    </wsdl:part>
    <wsdl:part name="Km_Left_Right" type="xsd:string">
        <wsdl:documentation>Size in km of the subset left and right the center location</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:message name="getsubsetorderResponse">
    <wsdl:part name="getsubsetorderReturn" type="xsd:string">
        <wsdl:documentation>This returns the order ID for the subset ID. An email with a link to the subset order would be dispatched to the email address provided.</wsdl:documentation>
    </wsdl:part>
</wsdl:message>

<wsdl:portType name="myServiceHandler">
    <wsdl:operation name="getproducts" parameterOrder="">
        <wsdl:input message="impl:getproductsRequest" name="getproductsRequest" />
        <wsdl:output message="impl:getproductsResponse" name="getproductsResponse" />
    </wsdl:operation>

    <wsdl:operation name="getbands" parameterOrder="Product">
        <wsdl:input message="impl:getbandsRequest" name="getbandsRequest" />
        <wsdl:output message="impl:getbandsResponse" name="getbandsResponse" />
    </wsdl:operation>

    <wsdl:operation name="getdates" parameterOrder="Latitude Longitude Product">
        <wsdl:input message="impl:getdatesRequest" name="getdatesRequest" />
        <wsdl:output message="impl:getdatesResponse" name="getdatesResponse" />
    </wsdl:operation>

    <wsdl:operation name="getsubset" parameterOrder="Latitude Longitude Product Band MODIS_Subset_Start_Date MODIS_Subset_End_Date Km_Above_Below Km_Left_Right">
        <wsdl:input message="impl:getsubsetRequest" name="getsubsetRequest" />
        <wsdl:output message="impl:getsubsetResponse" name="getsubsetResponse" />
    </wsdl:operation>

    <wsdl:operation name="getsubsetorder" parameterOrder="Latitude Longitude Product Email UID MODIS_Subset_Start_Date MODIS_Subset_End_Date Km_Above_Below Km_Left_Right">
        <wsdl:input message="impl:getsubsetorderRequest" name="getsubsetorderRequest" />
        <wsdl:output message="impl:getsubsetorderResponse" name="getsubsetorderResponse" />
    </wsdl:operation>

</wsdl:portType>

<wsdl:binding name="myServiceSoapBinding" type="impl:myServiceHandler">
    <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />

    <wsdl:operation name="getproducts">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="getproductsRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:input>
        <wsdl:output name="getproductsResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="getbands">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="getbandsRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:input>
        <wsdl:output name="getbandsResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="getdates">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="getdatesRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:input>
        <wsdl:output name="getdatesResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="getsubset">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="getsubsetRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:input>
        <wsdl:output name="getsubsetResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:output>
    </wsdl:operation>

    <wsdl:operation name="getsubsetorder">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="getsubsetorderRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:input>
        <wsdl:output name="getsubsetorderResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://daac.ornl.gov/MODIS_webservice" use="encoded" />
        </wsdl:output>
    </wsdl:operation>

</wsdl:binding>

<wsdl:service name="myServiceHandlerService">
    <wsdl:port binding="impl:myServiceSoapBinding" name="myService">
        <wsdlsoap:address location="http://daac.ornl.gov/cgi-bin/MODIS/GLBVIZ_1_Glb_subset/MODIS_webservice.pl" />
    </wsdl:port>
</wsdl:service>

</wsdl:definitions>

My generated proxy class is:

namespace FarmNet.Modis {
// .... I cut off code
[System.Web.Services.WebServiceBindingAttribute(Name="myServiceSoapBinding", Namespace="http://daac.ornl.gov/MODIS_webservice")]
public partial class myServiceHandlerService : System.Web.Services.Protocols.SoapHttpClientProtocol {

   // ........... code cut off
    /// <remarks/>
    public myServiceHandlerService() {

    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://daac.ornl.gov/MODIS_webservice", ResponseNamespace="http://daac.ornl.gov/MODIS_webservice")]
    [return: System.Xml.Serialization.SoapElementAttribute("getproductsReturn")]
    public string[] getproducts() {
        object[] results = this.Invoke("getproducts", new object[0]);
        return ((string[])(results[0]));
    }

    /// <remarks/>
    public void getproductsAsync() {
        this.getproductsAsync(null);
    }

    /// <remarks/>
    public void getproductsAsync(object userState) {
        if ((this.getproductsOperationCompleted == null)) {
            this.getproductsOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetproductsOperationCompleted);
        }
        this.InvokeAsync("getproducts", new object[0], this.getproductsOperationCompleted, userState);
    }

    private void OngetproductsOperationCompleted(object arg) {
        if ((this.getproductsCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getproductsCompleted(this, new getproductsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://daac.ornl.gov/MODIS_webservice", ResponseNamespace="http://daac.ornl.gov/MODIS_webservice")]
    [return: System.Xml.Serialization.SoapElementAttribute("getbandsReturn")]
    public string[] getbands(string Product) {
        object[] results = this.Invoke("getbands", new object[] {
                    Product});
        return ((string[])(results[0]));
    }

    /// <remarks/>
    public void getbandsAsync(string Product) {
        this.getbandsAsync(Product, null);
    }

    /// <remarks/>
    public void getbandsAsync(string Product, object userState) {
        if ((this.getbandsOperationCompleted == null)) {
            this.getbandsOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetbandsOperationCompleted);
        }
        this.InvokeAsync("getbands", new object[] {
                    Product}, this.getbandsOperationCompleted, userState);
    }

    private void OngetbandsOperationCompleted(object arg) {
        if ((this.getbandsCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getbandsCompleted(this, new getbandsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://daac.ornl.gov/MODIS_webservice", ResponseNamespace="http://daac.ornl.gov/MODIS_webservice")]
    [return: System.Xml.Serialization.SoapElementAttribute("getdatesReturn")]
    public string[] getdates(float Latitude, float Longitude, string Product) {
        object[] results = this.Invoke("getdates", new object[] {
                    Latitude,
                    Longitude,
                    Product});
        return ((string[])(results[0]));
    }

    /// <remarks/>
    public void getdatesAsync(float Latitude, float Longitude, string Product) {
        this.getdatesAsync(Latitude, Longitude, Product, null);
    }

    /// <remarks/>
    public void getdatesAsync(float Latitude, float Longitude, string Product, object userState) {
        if ((this.getdatesOperationCompleted == null)) {
            this.getdatesOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetdatesOperationCompleted);
        }
        this.InvokeAsync("getdates", new object[] {
                    Latitude,
                    Longitude,
                    Product}, this.getdatesOperationCompleted, userState);
    }

    private void OngetdatesOperationCompleted(object arg) {
        if ((this.getdatesCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getdatesCompleted(this, new getdatesCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://daac.ornl.gov/MODIS_webservice", ResponseNamespace="http://daac.ornl.gov/MODIS_webservice")]
    [return: System.Xml.Serialization.SoapElementAttribute("getsubsetReturn")]
    public ModisData getsubset(float Latitude, float Longitude, string Product, string Band, string MODIS_Subset_Start_Date, string MODIS_Subset_End_Date, string Km_Above_Below, string Km_Left_Right) {
        object[] results = this.Invoke("getsubset", new object[] {
                    Latitude,
                    Longitude,
                    Product,
                    Band,
                    MODIS_Subset_Start_Date,
                    MODIS_Subset_End_Date,
                    Km_Above_Below,
                    Km_Left_Right});
        return ((ModisData)(results[0]));
    }

    /// <remarks/>
    public void getsubsetAsync(float Latitude, float Longitude, string Product, string Band, string MODIS_Subset_Start_Date, string MODIS_Subset_End_Date, string Km_Above_Below, string Km_Left_Right) {
        this.getsubsetAsync(Latitude, Longitude, Product, Band, MODIS_Subset_Start_Date, MODIS_Subset_End_Date, Km_Above_Below, Km_Left_Right, null);
    }

    /// <remarks/>
    public void getsubsetAsync(float Latitude, float Longitude, string Product, string Band, string MODIS_Subset_Start_Date, string MODIS_Subset_End_Date, string Km_Above_Below, string Km_Left_Right, object userState) {
        if ((this.getsubsetOperationCompleted == null)) {
            this.getsubsetOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetsubsetOperationCompleted);
        }
        this.InvokeAsync("getsubset", new object[] {
                    Latitude,
                    Longitude,
                    Product,
                    Band,
                    MODIS_Subset_Start_Date,
                    MODIS_Subset_End_Date,
                    Km_Above_Below,
                    Km_Left_Right}, this.getsubsetOperationCompleted, userState);
    }

    private void OngetsubsetOperationCompleted(object arg) {
        if ((this.getsubsetCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getsubsetCompleted(this, new getsubsetCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

   // Code is cut off
[System.Xml.Serialization.SoapTypeAttribute(Namespace="http://daac.ornl.gov/MODIS_webservice")]
public partial class ModisData {

    private System.Nullable<float> xllcornerField;

    private System.Nullable<float> yllcornerField;

    private System.Nullable<float> cellsizeField;

    private System.Nullable<float> nrowsField;

    private System.Nullable<float> ncolsField;

    private string bandField;

    private string unitsField;

    private System.Nullable<float> scaleField;

    private System.Nullable<float> latitudeField;

    private System.Nullable<float> longitudeField;

    private string headerField;

    private string[] subsetField;

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> xllcorner {
        get {
            return this.xllcornerField;
        }
        set {
            this.xllcornerField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> yllcorner {
        get {
            return this.yllcornerField;
        }
        set {
            this.yllcornerField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> cellsize {
        get {
            return this.cellsizeField;
        }
        set {
            this.cellsizeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> nrows {
        get {
            return this.nrowsField;
        }
        set {
            this.nrowsField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> ncols {
        get {
            return this.ncolsField;
        }
        set {
            this.ncolsField = value;
        }
    }

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

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

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> scale {
        get {
            return this.scaleField;
        }
        set {
            this.scaleField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> latitude {
        get {
            return this.latitudeField;
        }
        set {
            this.latitudeField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public System.Nullable<float> longitude {
        get {
            return this.longitudeField;
        }
        set {
            this.longitudeField = value;
        }
    }

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

    /// <remarks/>
    [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
    public string[] subset {
        get {
            return this.subsetField;
        }
        set {
            this.subsetField = value;
        }
    }
 // Code is cut off
}

Now all the functions: getproducts(), getdates(), getbands() are all working correctly. The only function that does not work is getsubset(). I use Fiddler and see the soap response received correctly as :

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns1="http://daac.ornl.gov/MODIS_webservice">
    <soap:Body>
        <getsubsetResponse xmlns="http://daac.ornl.gov/MODIS_webservice">
            <tns1:getsubsetReturn xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="tns1:ModisData">
                <xllcorner xsi:type="xsd:float">12900942.51</xllcorner>
                <yllcorner xsi:type="xsd:float">-3785264.93</yllcorner>
                <cellsize xsi:type="xsd:float">463.312716528</cellsize>
                <nrows xsi:type="xsd:float">21</nrows>
                <ncols xsi:type="xsd:float">21</ncols>
                <band xsi:type="xsd:string">LC_Property_1</band>
                <units xsi:type="xsd:string">Not Available</units>
                <scale xsi:type="xsd:float">0</scale>
                <latitude xsi:type="xsd:float">-34</latitude>
                <longitude xsi:type="xsd:float">140</longitude>
                <header xsi:type="xsd:string">HDFname,...     </header>
                <subset soapenc:arrayType="xsd:string[1]" xsi:type="soapenc:Array">
                    <item xsi:type="xsd:string">MCD12Q1.A2001001....</item>
                </subset>
            </tns1:getsubsetReturn>
        </getsubsetResponse>
    </soap:Body>
</soap:Envelope>

My code-behind, where I call the web service:

myServiceHandlerClient o = new myServiceHandlerClient();
// This WORKS:
string[] products = o.getproducts();
// This does NOT work, data is returned with all null fields:
ModisData data = o.getsubset(-34, 140, "MCD12Q1", "LC_Property_1", "A2001001", "A2001001", "5", "5");

Ok, so from my research there can be a mismatch in namespace, but I cant find it. The namespace in the wsdl file and the namespace from the soap response are the same(that's why all other functions work). Also, I dont see any typo or anything wrong with the element names either.

What can be wrong here? Please help.

ps: I even tried to use WCF by adding service reference from visual studio to generate the proxy class. However, none of the functions work, they all return null.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文