|
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.
|
|
|
|
|
Hi.
I'm writing a C# program and I'm using XML like a DB for storing structured information. After a query in XPath, I obtain a list of XmlNode (or, in other words, an instance of XmlNodeList) and I would like to make another query inside this list.
Maybe this is confused; here's an example.
Let's suppose we have this XML fragment:
<items>
<item val="1"/>
<item val="0"/>
<item val="1"/>
</items>
and after a query like ./item[@val='1'] we retrive this list:
<item val="1"/>
<item val="1"/>
Now, How can I convert easily this XmlNodeList in a node without creating a new XmlDocument (I need to have the right reference to nodes) so I will make another query on it? Or maybe how to call SelectNodes directly in the XmlNodeList (Yeah, I know: there's no SelectNodes in XmlNodeList)? Again, maybe it is possible to create a temporary node and insert the selected nodes into it.
Thanks in advance,
Atropo
P.S. Sorry if the question is a bit confusing: I'm not very good with english.
|
|
|
|
|
Atropus wrote: How can I convert easily this XmlNodeList in a node
That does not make sense, I can't understand what you want. Perhaps you could have provided the resultant example xml that you desire to create?
led mike
|
|
|
|
|
Hi all,
I want to know how can I write data that has beeb read from sql server
database to XML file. I doesn't have any Idea in working with XML.
please suggest be how do I meet my requirement.
Thank u all,
kiran
|
|
|
|
|
|
xml data
<?xml version="1.0" ?>
<statement>
<accounts>
<account number="22">
<currency symbol="USD">
<transactions>
<transaction>
<id>1</id>
</transaction>
</transactions>
</currency>
<currency symbol="EUR">
<transactions>
<transaction>
<id>2</id>
</transaction>
</transactions>
</currency>
</account>
</accounts>
</statement>
transformed with msxml parser using stylesheet
<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" standalone="yes"/>
<xsl:template match="/">
<xsl:element name="VFPData">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="/statement/accounts/account/currency/transactions/*">
<xsl:element name="result">
<xsl:element name="id"><xsl:value-of select="id"/></xsl:element>
<xsl:element name="currency"><xsl:value-of
select="../../../currency/@symbol"/></xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
produces
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<VFPData><result>
<id>1</id>
<currency>USD</currency>
</result>
<result><id>2</id>
<currency>USD</currency>
</result></VFPData>
In this output currency element value for id 2 is wrong: it must be EUR
How to change stylesheet so that EUR is in id 2 record ?
Andrus.
Andrus
|
|
|
|
|
I believe you just need to change this line:
"../../../currency/@symbol"
to this:
"../../@symbol"
|
|
|
|
|
I wish Use a or several xml file into My a xml file (Orginal File) that in During Open File,was contain from attribute other external xml files.
for example use of "src" ?
please help me apace.
tanx
|
|
|
|
|
hamedmot wrote: please help me apace.
This is a largely english site, you need to get help from someone that speaks english with your posts because they don't make any sense.
led mike
|
|
|
|
|
Does anyone have or know about a XSLT-file that is either "open-source" or license free that can generate HTML for displaying the content of any XML-file? (Similar to the internal XSLT Internet Explorer uses for displaying XML)
|
|
|
|
|
open source XSLT file? hehehe that's a good one!
Yes I have found similar years ago by googling around. Also created my own it's not that difficult, you just use XSLT form of recursion. However the simplest mechanism is to just get the XSLT that Internet Explorer uses, it is stored in the MSXML(N).DLL. If you use Visual Studio you can open the DLL in it's resource editor and copy the XSLT which is stored as a resource right out into your own file. If I remember correctly the resource name is not obvious.
You can also embed it as a resource in your own project. I have also seen noise about people getting the resource from MSXML at runtime. That approach means you are using which ever version the user has installed on his PC so that solution might have some benefits for certain projects.
led mike
|
|
|
|
|
I’m having a problem setting up schema validation using regular expressions - I have been stuck on this for some time and would appreciate some help...
I have a set of allowed characters that I could describe using this regular expression:
[\w?\-?.?\s?\'?,?#?-[_]]
This means that I allow any alphanumeric characters and characters like dash, period, spaces, apostrophe, comma, and number (hash) symbol. The last part of the expression tries to exclude underscore since \w allows it, and my application does not like underscores.
The problem is that this is an allowed set of characters and I am using the XSD pattern facet so that I can use schema validation to find rogue characters. XSD validation fails when the expression in the pattern facet does not match. My pattern looks like this:
xs:pattern="[\w?\-?.?\s?\'?,?#?-[_]]"
This basically works except that when characters not in range are present, the expression still matches. So if I add an @ or % symbol somewhere in the data, the expression happily matches even though there is invalid data present.
I looked at groups, forward, and reverse references, conditionals, etc. I have also tried to match on characters not in the set ( like this: [^\w?\-?.?\s?\'?,?#?] ), but that does not help since the presence of disallowed characters actually causes the expression to match thereby causing schema validation to pass!
The set of allowed characters is much smaller than the set of disallowed characters, so it would not be practical to create an expression having disallowed characters.
Any advice?
Erik Westermann - wWorkflow.net - (primarily)BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453
|
|
|
|
|
Well, in case anyone is interested, I solved my problem. Schema validation turned out to be too limited to handle all cases, so now I use schema validation combined with rules in the BizTalk Rules Engine (this was part of a larger BizTalk-based solution).
So, schema validation catches more obvious, structural issues whereas the Business Rules make it easier to validate based on regular expressions, etc.
Erik Westermann - wWorkflow.net - BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453
|
|
|
|
|
Hello,
I was trying to read an xml file using C#, but it's not reading the values in the parent nodes.
I am outputting the values to a text file. I have everything in the text file except for the values in the parent nodes.
Here's some code:
newFName = fname.Substring(0, fname.Length - 4) + ".DAT";
System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath(newFName));
XmlTextReader reader = new XmlTextReader("C:\\Projects\\CSNew2\\" + fname);
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
break;
case XmlNodeType.Text:
sw.WriteLine(reader.Value);
break;
case XmlNodeType.EndElement:
break;
}
}
sw.Close();
Any ideas?
Thanks.
|
|
|
|
|
Hai all ,
i need to create(result will be xml) by using querystring
xyz.aspx?customer_id=&first_name=&last_name=&email=sun@sun.com&phone=
it will display xml like
<?xml version="1.0" encoding="utf-8"?>
<livelookup version="1.0" columns="first_name,last_name">
<customer>
<customer_id>sunnyb</customer_id>
<first_name></first_name>
<last_name></last_name>
<email>sun@sun.com</email>
<phone</phone>
<organization></organization>
<password></password>
</customer>
</livelookup>
Thanks in advance
Thanks
Subbu.
|
|
|
|
|
Hi frnds..
Im using for-each and in a particular cell i have to create link and should open other worksheet of the same workbook..
I have used generate_id function but at runtime i will not able to get the sheet name and attach the link do that sheet...
Help me out if there is any other way...
Thnks...
|
|
|
|
|
I've been wondering about this and I've been using IXMLDOMNodePtr.
Is there a difference bet. IXMLDOMNodePtr & IXMLDOMNode *? Which is better than the other??
How come the word Ptr becomes equated with * in actual code??
Any idea or any links for this info??
Thanks!
|
|
|
|
|
It's just a macro, they are the same,
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Hello alls
I am writing a program in which i need to display XML data to table row in loop, in my program i can read XML and also display it using alert() function, but i am not able to display that XML to in table row. my program code is below. Can any one help me regarding it.
function RT(str)
{
for(var i=0; i<6; i++)
{
alert(str.substring(i,1));
}
}
text = new Array();
function parseXML()
{
var module = document.getElementById('module').value;
var version = document.getElementById('version').value;
var s_key = document.getElementById('s_key').value;
var uid = document.getElementById('uid').value;
var lang = document.getElementById('lang').value;
var strUrl = 'api/index.php?module='+module+'&version='+version+'&s_key='+s_key+'&uid='+uid+'&lang='+lang;
var str_xml='';
AjaxRequest.get(
{
'url':strUrl
,'onSuccess':function(req)
{
text = req.responseText;
text = text.substring(4);
text = TrimAll(text);
alert(text);
try //Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(text);
}
catch(e)
{
try // Firefox, Mozilla, Opera, etc.
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(text,"text/xml");
}
catch(e)
{
alert(e.message);
return;
}
}
var data_node=xmlDoc.getElementsByTagName("data").item(0);
var data_node_len=data_node.childNodes.length;
for(var i=0;i<=(data_node_len/2);i++)
{
var id =data_node.getElementsByTagName("id")[i].childNodes[0].nodeValue;
// var dev_name =data_node.getElementsByTagName("device_name")[i].childNodes[0].nodeValue;
// var rep_int =data_node.getElementsByTagName("reporting_interval")[i].childNodes[0].nodeValue;
document.getElementById("device_name"+"i").innerHTML =data_node.getElementsByTagName("device_name")[i].childNodes[0].nodeValue;
document.getElementById("report_inter"+"i").innerHTML =data_node.getElementsByTagName("reporting_interval")[i].childNodes[0].nodeValue;
}
}
}
);
}
here : device_name and report_inter and that td id's where i want to show it ..... This program is not working can any one please told me where i am wrong.
Regard's
Kaushik
|
|
|
|
|
Hi,
I am just new to XSL. Hope anyone can help regarding my problem.
Problem: I only want to display the node for ITEM/DESC and ITEM1/DESC1. How to make conditions or file the xml using XSL.
THank you.
jollymj23
Sample.xsl
<xsl:for-each select="root/child" xmlns:xsl="#unknown">
<xsl:value-of select="childnode">
<xsl:for-each>
Sample.xml
<root>
<child>
<node>
<childnode>ITEM
<childnode>DESC
<node>
<childnode>ITEM1
<childnode>DESC1
<child>
<node>
<childnode>ORDER
<childnode>DESC
|
|
|
|
|
If I've got your sample correct:
<root>
<child>
<node>
<childnode>ITEM</childnode>
<childnode>DESC</childnode>
</node>
<node>
<childnode>ITEM1</childnode>
<childnode>DESC1</childnode>
</node>
</child>
<child>
<node>
<childnode>ORDER</childnode>
<childnode>DESC</childnode>
</node>
</child>
</root>
You can use XPath to filter the result:
<xsl:for-each select="//node[starts-with(string(childnode),'ITEM')]">
<xsl:value-of select="position()"/>
<xsl:text> </xsl:text>
</xsl:for-each>
This should print out 1 2 as it will select the first two node elements.
|
|
|
|
|
Hi,
I'm trying to work out how to do the following..
Within an XML data source, each <data-item> has a <countries> element containing a comma-separated list of country-codes e.g.
<data-item> <countries>GBR,ARG,IRL</countries> </data-item>
Within the XSLT I've build a lookup like...
<CountryList><Country><Code>GBR</Code><Name>United Kingdon</Name></Country></CountryList>.
I want to get a list of all the countries, in <CountryList> order, for which there are entries in one or more <countries> elements.
I've tried using exsl:node-set to build a set of nodes from the CountryList, then for-each to iterate those nodes, but can't work out how, within the for-each, to get an if test to work (somehow using contains() to see if the code for that country is within any <countries> element).
Anyone got any suggestions?
|
|
|
|
|
Hi,
i'm really new to XML, XSL
i'm trying to show a string that is Generated by a Given Loaigcal Algorithem From a JS Function
(I.E if status is Failed so Display XXXX if Passed XXYY .... )
i'm trying to give The String some Colors Like :
I'm (In blue) Trying (In Red)
any IDEA???
Have Fun
Never forget it
|
|
|
|
|
what does displaying colored text using javascript have to do with XML and XSLT?
half-life wrote: Generated by a Given Loaigcal Algorithem
What does Loaigcal mean?
led mike
|
|
|
|
|