Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 15th, 2008, 06:38 AM
Registered User
 
Join Date: Jul 2008
Location: london, london, United Kingdom.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Web Method Returning a complex Custom data type.

Hi,
I am facing a problem in capturing and retreving data from a webmethod response.I am calling web methods on remote server.So I have included the web reference of the webservice in my Vs2005 solution.But the main problem is the webmethods are returning custom Array datatypes.The coustom data types are the other class types.I am facing problem in accessing the returned data.I think my client side code is creating the main problem.Please find the Below code(Auto generated code).and Please help me.


The Defination webmethod which I am calling.which is a part of a class called.

public partial class hbcontent : System.Web.Services.Protocols.SoapHttpClientProtoc ol
{

-----Many other Parametrs/methods Below one is the sample---

[System.Web.Services.Protocols.SoapRpcMethodAttribu te("", RequestNamespace="http://remote.api", ResponseNamespace="http://remote.api")]
        [return: System.Xml.Serialization.SoapElementAttribute("get CountryDataReturn")]
        public Map getCountryData(string key, string language, string country) {
            object[] results = this.Invoke("getCountryData", new object[] {
                        key,
                        language,
                        country});
            return ((Map)(results[0]));
        }
}

----Definition of the other classes :----

[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Xml", "2.0.50727.2344")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.SoapTypeAttribute(Namespa ce="http://xml.apache.org/xml-soap")]
    public partial class Map {

        private mapItem[] itemField;

        /// <remarks/>
        public mapItem[] item {
            get {
                return this.itemField;
            }
            set {
                this.itemField = value;
            }
        }
    }

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Xml", "2.0.50727.2344")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("c ode")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespa ce="http://xml.apache.org/xml-soap")]
    public partial class mapItem {

        private object keyField;

        private object valueField;

        /// <remarks/>
        [System.Xml.Serialization.SoapElementAttribute(IsNu llable=true)]
        public object key {
            get {
                return this.keyField;
            }
            set {
                this.keyField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.SoapElementAttribute(IsNu llable=true)]
        public object value {
            get {
                return this.valueField;
            }
            set {
                this.valueField = value;
            }
        }
    }

WSDL file for the corresponding section:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://remote.api" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://remote.api" xmlns:intf="http://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:types>
  <schema targetNamespace="http://rpc.xml.coldfusion" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://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://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>

My client Code:

static void Main(string[] args)
   {

hbcontent hbc = new hbcontent();

Map map2 = new Map();

map2 = (Map)hbc.getCountryData("Key12345", "en", "new-zealand");

}

When run the above code nothing is returned to the map2.But the web method is returning the data,which I can see using some Http tools like Wfecth and fiddler.

The sample data captured in fiddler is:

<?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:getCountryDataResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://remote.api">
   <getCountryDataReturn 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">RESPONSE</key>
     <value xsi:type="ns2:Map">
      <item>
       <key xsi:type="soapenc:string">LOCATIONS</key>
       <value soapenc:arrayType="xsd:anyType[10]" xsi:type="soapenc:Array">
        <value xsi:type="ns2:Map">
         <item>
          <key xsi:type="soapenc:string">LNAME</key>
          <value xsi:type="soapenc:string">Abel Tasman</value>
         </item>
         <item>
          <key xsi:type="soapenc:string">INTRO</key>
          <value xsi:type="soapenc:string"></value>
         </item>
         <item>
          <key xsi:type="soapenc:string">IMG</key>
          <value xsi:type="soapenc:string"></value>
         </item>
         <item>
          <key xsi:type="soapenc:string">NAME</key>
          <value xsi:type="soapenc:string">abel-tasman</value>
         </item>
         <item>
          <key xsi:type="soapenc:string">LANGUAGE</key>
          <value xsi:type="soapenc:string">en</value>
         </item>
         <item>
          <key xsi:type="soapenc:string">ID</key>
          <value xsi:type="soapenc:int">9862</value>
         </item>
        </value>
        <value xsi:type="ns2:Map">
         <item>
          <key xsi:type="soapenc:string">LNAME</key>
          <value xsi:type="soapenc:string">Ahipara</value>
         </item>
         <item>
          <key xsi:type="soapenc:string">INTRO</key>
          <value xsi:type="soapenc:string"></value>
         </item>
         <item>
          <key xsi:type="soapenc:string">IMG</key>
          <value xsi:type="soapenc:string"></value>
         </item>
         <item>
          <key xsi:type="soapenc:string">NAME</key>
          <value xsi:type="soapenc:string">ahipara</value>
         </item>
         <item>
          <key xsi:type="soapenc:string">LANGUAGE</key>
          <value xsi:type="soapenc:string">en</value>
         </item>
         <item>
          <key xsi:type="soapenc:string">ID</key>
          <value xsi:type="soapenc:int">9646</value>
         </item>
        </value>
       </value>
      </item>
      <item>
       <key xsi:type="soapenc:string">CONTENT</key>
       <value xsi:type="ns2:Map">
        <item>
         <key xsi:type="soapenc:string">LNAME</key>
         <value xsi:type="soapenc:string">New Zealand</value>
        </item>
        <item>
         <key xsi:type="soapenc:string">EXCHRATE</key>
         <value xsi:type="soapenc:decimal">1.3170</value>
        </item>
        <item>
         <key xsi:type="soapenc:string">INTRO</key>
         <value xsi:type="soapenc:string"></value>
        </item>
        <item>
         <key xsi:type="soapenc:string">CURRENCY</key>
         <value xsi:type="soapenc:string">New Zealand Dollars</value>
        </item>
        <item>
         <key xsi:type="soapenc:string">IMG</key>
         <value xsi:type="soapenc:string"></value>
        </item>
        <item>
         <key xsi:type="soapenc:string">CONTINENT</key>
         <value xsi:type="soapenc:string">au</value>
        </item>
        <item>
         <key xsi:type="soapenc:string">NAME</key>
         <value xsi:type="soapenc:string">new-zealand</value>
        </item>
        <item>
         <key xsi:type="soapenc:string">LANGUAGE</key>
         <value xsi:type="soapenc:string">en</value>
        </item>
        <item>
         <key xsi:type="soapenc:string">ID</key>
         <value xsi:type="soapenc:int">212</value>
        </item>
       </value>
      </item>
     </value>
    </item>
    <item>
     <key xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">METHOD</key>
     <value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">getCountryData(KEY=******,LANGUAGE=en,COUNTRY=ne w-zealand)</value>
    </item>
   </getCountryDataReturn>
  </ns1:getCountryDataResponse>
 </soapenv:Body>
</soapenv:Envelope>


I need to retreve the above data and use it on my presentation layer.please help me with this.it would be a great help for me.

Thanks in advance.:)



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Service, Custom Control, Custom Return Type robzyc ASP.NET 2.0 Basics 6 June 10th, 2008 09:03 AM
What is '{no name}' is 'empty' in complex type? 2BOrNot2B XML 2 March 26th, 2008 05:35 PM
Return a custom type from a web service gabrieldcr2 .NET Web Services 1 November 27th, 2005 01:26 PM
Complex Data Type BSkelding .NET Web Services 5 May 12th, 2005 03:30 PM
unordered elements in complex type mandabear XML 0 September 3rd, 2004 12:08 PM



All times are GMT -4. The time now is 03:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.