User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the RSS, Web Services and SOAP section within the Web Development category of DaniWeb, a massive community of 426,811 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,926 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our RSS, Web Services and SOAP advertiser: Programming Forums
Views: 1499 | Replies: 0
Reply
Join Date: Jul 2008
Posts: 2
Reputation: saisunil1978 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
saisunil1978 saisunil1978 is offline Offline
Newbie Poster

Client side code for a Web Method Returning a complex Custom data type.

  #1  
Jul 17th, 2008
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.SoapHttpClientProtocol 
{

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

[System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="http://remote.api", ResponseNamespace="http://remote.api")]
        [return: System.Xml.Serialization.SoapElementAttribute("getCountryDataReturn")]
        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("System.Xml", "2.0.50727.2344")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.SoapTypeAttribute(Namespace="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("System.Xml", "2.0.50727.2344")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespace="http://xml.apache.org/xml-soap")]
    public partial class mapItem {
        
        private object keyField;
        
        private object valueField;
        
        /// <remarks/>
        [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
        public object key {
            get {
                return this.keyField;
            }
            set {
                this.keyField = value;
            }
        }
        
        /// <remarks/>
        [System.Xml.Serialization.SoapElementAttribute(IsNullable=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 created by Macromedia ColdFusion MX version-->
 <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=new-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.
Last edited by Tekmaven : Jul 17th, 2008 at 12:37 pm. Reason: Code tags
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb RSS, Web Services and SOAP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the RSS, Web Services and SOAP Forum

All times are GMT -4. The time now is 8:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC