<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<MasterDetailsResponse xmlns="http://192.168.100.173/ArvindMill/">
<MasterDetailsResult>
<GetAllMasterDetail>
<TABLENAME>item_master</TABLENAME>
<ITEMID>1</ITEMID>
<ITEMTYPE>CTS</ITEMTYPE>
<GROUP />
<VARIETY />
<FORM />
<STATUS />
<ITEM />
<GRADE />
<TYPE />
</GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>item_master</TABLENAME>
<ITEMID>2</ITEMID>
<ITEMTYPE>AGS</ITEMTYPE>
<GROUP /><VARIETY />
<FORM />
<STATUS />
<ITEM />
<GRADE />
<TYPE />
</GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>tablet_taluka_master</TABLENAME>
<VILLAGE>Anturli</VILLAGE>
<TALUKA>Anturli</TALUKA>
<TABLETUSERCODE />
<TABLETUSERNAME /><TABLETCODE />
<TABLETTALUKAID />
</GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>tablet_taluka_master</TABLENAME>
<VILLAGE>Bortha</VILLAGE>
<TALUKA>Sadgavan</TALUKA>
<TABLETUSERCODE /><TABLETUSERNAME />
<TABLETCODE />
<TABLETTALUKAID /></GetAllMasterDetail>
<GetAllMasterDetail>
<TABLENAME>tablet_taluka_master</TABLENAME>
<VILLAGE>Kukarmunda</VILLAGE>
<TALUKA>Kukarmunda</TALUKA>
<TABLETUSERCODE />
<TABLETUSERNAME /><TABLETCODE /><TABLETTALUKAID />
</GetAllMasterDetail>
The above code is the response returned from soapobject in android. How to retrieve the data from the above XML file? I want to display it in list view and the response returned from the soapobject contains more than one table so how to retrieve it?
If your are using Java use SAX Parser
Related
Here is my Nlog.Config code.
<nlog>
<variable name="logFilePath" value="C:\NLog\IDG-${shortdate}.log" />
<targets>
<target name="logfile"
xsi:type="File"
fileName="${logFilePath}"
layout="${longdate} LEVEL=${level:upperCase=true}: ${message}"
keepFileOpen="true" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
<logger name="*" minlevel="Info" writeTo="logfile" />
<logger name="*" minlevel="Warn" writeTo="file"/>
</rules>
</nlog>
and am defining this in my class
private static Logger logger = LogManager.GetCurrentClassLogger();
and then I'm logging the error as:
catch (Exception ex)
{
logger.Error(ex.Message,"test");
}
Can anyone please suggest me if there is any better way to do this, I don't see the file logging in the destined folder.
It seems that you may not be referencing the config section correctly. Try changing your main config file to something like this and remove the Nlog.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<variable name="logFilePath" value="C:\temp\output.log" />
<targets>
<target name="logfile"
xsi:type="File"
fileName="${logFilePath}"
layout="${longdate} LEVEL=${level:upperCase=true}: ${message}"
keepFileOpen="true" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
<logger name="*" minlevel="Info" writeTo="logfile" />
<logger name="*" minlevel="Warn" writeTo="file"/>
</rules>
</nlog>
</configuration>
I'm tying to call an OAuth token service to retrieve the token.
Below is my proxy. This is a simple rest endpoint call which retrieves the token. For testing purpose I'm trying to log the token in the response.
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="sla_proxy_svc_vo2" startOnLoad="true" trace="disable"
transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<log level="custom">
<property name="msg" value="*****INITIATING*****" />
</log>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:echo="http://echo.services.core.carbon.wso2.org"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<nstxt:text xmlns:nstxt="http://ws.apache.org/commons/ns/payload">grant_type=client_credentials&client_id=G6Dk_3ZdrXOfPiuctufVq6GfTWoa&client_secret=jxA8NTkEClE5xGUvGvvhVTDyXM4a</nstxt:text>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args />
</payloadFactory>
<log level="custom">
<property name="msg" value="*****BEFORE TOKEN SERVICE CALL*****" />
</log>
<log level="full" />
<property name="HTTP_METHOD" scope="axis2" type="STRING"
value="POST" />
<property name="messageType" scope="axis2" type="STRING"
value="text/plain" />
<property name="ContentType" scope="axis2" type="STRING"
value="text/plain" />
<property name="Accept" scope="axis2" type="STRING"
value="application/json" />
<send>
<endpoint>
<http format="rest" method="post" trace="disable"
uri-template="http://10.236.70.9:8281/token" />
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="custom">
<property name="msg" value="******OUT SEQUENCE*******" />
</log>
<log level="full" />
<send />
</outSequence>
<faultSequence />
</target>
</proxy>
I'm getting the below response when I call.
DEBUG {org.apache.synapse.transport.http.wire} - << "HTTP/1.1 415 Unsupported Media Type[\r][\n]" {org.apache.synapse.transport.http.wire}
DEBUG {org.apache.synapse.transport.http.wire} - << "X-Frame-Options: DENY[\r][\n]" {org.apache.synapse.transport.http.wire}
DEBUG {org.apache.synapse.transport.http.wire} - << "X-XSS-Protection: 1; mode=block[\r][\n]" {org.apache.synapse.transport.http
Will be please if anyone can guide me of I'm doing anything wrong here.
I was able to call the service with the following payload.
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<root>
<grant_type>client_credentials</grant_type>
<client_id>G6Dk_3ZdrXOfPiuctufVq6GfTWoa</client_id>
<client_secret>jxA8NTkEClE5xGUvGvvhVTDyXM4a</client_secret>
</root>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args />
</payloadFactory>
Also had to add the content type as below.
<property name="messageType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded" />
<property name="ContentType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded" />
This worked and retrieved the token.
Here is a template I'm using in a component to set the oAuth token, you could probably adapt it a bit for your case (sounds like you do not need grantType or user credentials)
<?xml version="1.0" encoding="UTF-8"?>
<template name="getToken" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="tokenURL"/>
<parameter name="clientId"/>
<parameter name="clientSecret"/>
<parameter name="grantType"/>
<sequence>
<property description="Base64 crendetials" expression="base64Encode(fn:concat($func:clientId,':',$func:clientSecret))" name="credentials" scope="default" type="STRING"/>
<property description="Authentication" expression="fn:concat('Basic ', get-property('credentials'))" name="Authorization" scope="transport" type="STRING"/>
<header name="Content-Type" scope="transport" value="application/x-www-form-urlencoded"/>
<property name="messageType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded"/>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<property expression="$func:tokenURL" name="uri.var.authUrl" scope="default" type="STRING"/>
<property expression="$func:grantType" name="uri.var.grantType" scope="default" type="STRING"/>
<call blocking="true">
<endpoint>
<http method="post" uri-template="{uri.var.authUrl}?grant_type={uri.var.grantType}"/>
</endpoint>
</call>
<property expression="json-eval($.access_token)" name="OAuth_Token" scope="default" type="STRING"/>
<property action="remove" description="Remove Headers" name="TRANSPORT_HEADERS" scope="axis2"/>
<property description="Authorization" expression="fn:concat('Bearer ',get-property('OAuth_Token'))" name="Authorization" scope="transport" type="STRING"/>
</sequence>
</template>
I'm using TFS OData service to create work item which is work fine. now i need to get id of work item and insert into database for later reference can anyone guide me direction for this ?
here is what i get as a response.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="https://tfsodata.visualstudio.com/DefaultCollection/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:etag="W/"datetime'2013-08-31T10%3A23%3A21.1439028%2B00%3A00'"" xmlns="http://www.w3.org/2005/Atom">
<id>https://tfsodata.visualstudio.com/DefaultCollection/WorkItems(0)</id>
<title type="text">my test work item</title>
<summary type="text">test work item created by isuru http://www.google.com</summary>
<updated>2013-08-31T10:23:21Z</updated>
<author>
<name />
</author>
<link rel="edit" title="WorkItem" href="WorkItems(0)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href="WorkItems(0)/Attachments" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Links" type="application/atom+xml;type=feed" title="Links" href="WorkItems(0)/Links" />
<category term="Microsoft.Samples.DPE.ODataTFS.Model.Entities.WorkItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">0</d:Id>
<d:Project>My Website</d:Project>
<d:Type>Product Backlog Item</d:Type>
<d:WebEditorUrl m:null="true" />
<d:AreaPath m:null="true" />
<d:IterationPath m:null="true" />
<d:Revision m:type="Edm.Int32">0</d:Revision>
<d:Priority m:null="true" />
<d:Severity m:null="true" />
<d:StackRank m:type="Edm.Double">0</d:StackRank>
<d:AssignedTo m:null="true" />
<d:CreatedDate m:type="Edm.DateTime">2013-08-31T10:23:21.1419032+00:00</d:CreatedDate>
<d:CreatedBy m:null="true" />
<d:ChangedDate m:type="Edm.DateTime">2013-08-31T10:23:21.1439028+00:00</d:ChangedDate>
<d:ChangedBy m:null="true" />
<d:ResolvedBy m:null="true" />
<d:Title>my test work item</d:Title>
<d:State m:null="true" />
<d:Reason m:null="true" />
<d:CompletedWork m:type="Edm.Double">0</d:CompletedWork>
<d:RemainingWork m:type="Edm.Double">0</d:RemainingWork>
<d:Description>test work item created by isuru http://www.google.com</d:Description>
<d:ReproSteps m:null="true" />
<d:FoundInBuild m:null="true" />
<d:IntegratedInBuild m:null="true" />
<d:AttachedFileCount m:type="Edm.Int32">0</d:AttachedFileCount>
<d:HyperLinkCount m:type="Edm.Int32">0</d:HyperLinkCount>
<d:RelatedLinkCount m:type="Edm.Int32">0</d:RelatedLinkCount>
<d:Risk m:null="true" />
<d:StoryPoints m:type="Edm.Double">0</d:StoryPoints>
<d:OriginalEstimate m:type="Edm.Double">0</d:OriginalEstimate>
<d:BacklogPriority m:type="Edm.Double">0</d:BacklogPriority>
<d:BusinessValue m:type="Edm.Int32">0</d:BusinessValue>
<d:Effort m:type="Edm.Double">0</d:Effort>
<d:Blocked m:null="true" />
<d:Size m:type="Edm.Double">0</d:Size>
</m:properties>
</content>
</entry>
What I did was adding a Guid to a random field that you are not using and query for that Guid afterwards.
wi.Title = "New Work Item";
wi.FoundInBuild = Guid.NewGuid().ToString();
wi.Type = "Bug";
wi.Project = "TestProject";
context.AddToWorkItems(wi);
context.SaveChanges();
Debug.WriteLine(String.Format("Work item created"));
var createdWi = context.WorkItems.Where( d => d.FoundInBuild == wi.FoundInBuild);
I have an XML response as included below. How can I obtain the element?
In rails I have:
xml = REXML::Document.new(contacts_as_xml)
Rails.logger.info xml[1].attributes["id"]
Which is not returning 'user#company.com'
Thanks
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:gContact="http://schemas.google.com/contact/2008" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gd="http://schemas.google.com/g/2005" gd:etag="W/"Ck8BQ38yfyt7I2A9WhNSFk8."">
<id>user#company.com</id>
<updated>2012-10-30T18:14:12.197Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" />
<title>Users's Contacts</title>
<link rel="alternate" type="text/html" href="http://www.google.com/" />
<link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/myuser%40mysite.com/full" />
<link rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/myuser%40mysite.com/full" />
<link rel="http://schemas.google.com/g/2005#batch" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/myuser%40mysite.com/full/batch" />
<link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/myuser%40mysite.com/full?max-results=10000" />
<author>
<name>User Howdy</name>
<email>user#company.com</email>
</author>
<generator version="1.0" uri="http://www.google.com/m8/feeds">Contacts</generator>
<openSearch:totalResults>2</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>10000</openSearch:itemsPerPage>
<entry gd:etag=""QXc5eDVSLit7I2A9WhdSFk8PTgU."">
<id>http://www.google.com/m8/feeds/contacts/myuser%40mysite.com/base/970a99881a51f3</id>
<updated>2011-07-25T20:31:50.920Z</updated>
<app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-25T20:31:50.920Z</app:edited>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" />
<title>Jon Paris</title>
<link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/myuser%40mysite.com/970a99881a51f3" />
<link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/myuser%40mysite.com/full/970a99881a51f3" />
<link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/myuser%40mysite.com/full/970a99881a51f3" />
<gd:name>
<gd:fullName>Jon Adams</gd:fullName>
<gd:givenName>Jon</gd:givenName>
<gd:familyName>Adams</gd:familyName>
</gd:name>
<gd:email rel="http://schemas.google.com/g/2005#other" address="jon#adams.com" primary="true" />
<gd:email rel="http://schemas.google.com/g/2005#home" address="jon#adams.com" />
</entry>
<entry gd:etag=""R3YzcTFbKit7I2A9WhJbE00ORQY."">
<id>http://www.google.com/m8/feeds/contacts/myuser%40mysite.com/base/1229b5e8eeef3e3</id>
<updated>2012-09-22T08:57:06.889Z</updated>
<app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-22T08:57:06.889Z</app:edited>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" />
<title></title>
<link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/myuser%40mysite.com/1229b5e8eeef3e3" gd:etag=""UQZOJlcjWit7I2BmGBdVTzBfL2E2GGI5Myk."" />
<link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/myuser%40mysite.com/full/1229b5e8eeef3e3" />
<link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/myuser%40mysite.com/full/1229b5e8eeef3e3" />
<gd:email rel="http://schemas.google.com/g/2005#other" address="person#site.com" primary="true" />
<gd:email rel="http://schemas.google.com/g/2005#home" address="person#gmail.com" />
</entry>
</feed>
Problem
When you do:
xml[1].attributes["id"]
You are getting the text node of <?xml version='1.0' encoding='UTF-8'?> and then trying to get its id attribute. Since it does not exist, you got blank.
Solution
You want:
xml.root.elements['id'].text
#=> user#company.com
Note that "user#company.com" is a text node of the id element. It is not an attribute.
How do you define a list of complex type items in WSDL?
I have a rather simple WSDL with 2 complex types
<xsd:complexType name="itemProperty">
<xsd:all>
<xsd:element name="name" type="xsd:string" />
<xsd:element name="value" type="xsd:string" />
<xsd:element name="type" type="xsd:string" />
</xsd:all>
</xsd:complexType>
Then i'm trying to make a list of this complexType like this:
<xsd:complexType name="itemPropertyList">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:sequence>
<xsd:element name="item" type="tns:itemProperty"
maxOccurs="unbounded" minOccurs="0" />
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
I intend to use this list
<message name="getListRequest"></message>
<message name="getListResponse">
<part name="return" type="tns:itemPropertyList" />
</message>
<operation name="getList">
<documentation>Returns an array.</documentation>
<input message="tns:getListRequest" />
<output message="tns:getListResponse" />
</operation>
Instead of a list of elements of type itemProperty, I get this reply, no matter what variations i've tryed (including replacing the base item with the explicit string elements)
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getListResponse>
<return SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">name</key>
<value xsi:type="xsd:string">name_4c3b38b0b77ae</value>
</item>
<item>
<key xsi:type="xsd:string">value</key>
<value xsi:type="xsd:string">name_4c3b38b0b77ee</value>
</item>
<item>
<key xsi:type="xsd:string">type</key>
<value xsi:type="xsd:string">name_4c3b38b0b782b</value>
</item>
</item>
</return>
</ns1:getListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Any ideas? What is this ns2:Map thing? It's been haunting me for over a week!
Solved.
I used the AXIS model for delivering lists. This involved extending the namespaces attributes to include some extra encodings. I don't know which did the trick, I just added as many as possible while resolving conflicts with the help of eclipse's WSDL editor.
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="urn:mynamespace"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="urn:mynamespace"
xmlns:ns1="http://org.apache.axis2/xsd"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:ax21="http://example.org/xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
Also I added 2 extra attributes to declare qualified-form attributes and elements within the schema
<xsd:schema targetNamespace="urn:mynamespace" attributeFormDefault="qualified" elementFormDefault="qualified">
...
</xsd:schema>
Instead of relying on the ComplexType declaration to make a "nillable" unbounded sequence of a complex type within my schema, I switched to declare an element like this:
<xsd:element name="getListResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="tns:itemProperty" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Then, when defining the message part for the operation I used
<message name="getListResponse">
<part name="parameters" element="tns:getListResponse" />
</message>
instead of
<message name="getListResponse">
<part name="return" type="tns:itemPropertyList" />
</message>
This resulted in a correct enveloper returned:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:mynamespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getListResponse>
<parameters xsi:type="ns1:getListResponse">
<return xsi:type="ns1:itemProperty">
<name xsi:type="xsd:string">name4c4417b644a8e</name>
<value xsi:type="xsd:string">value4c4417b644aaa</value>
<type xsi:type="xsd:string">type4c4417b644ae8</type>
</return>
<return xsi:type="ns1:itemProperty">
<name xsi:type="xsd:string">name4c4417b644b26</name>
<value xsi:type="xsd:string">value4c4417b644b64</value>
<type xsi:type="xsd:string">type4c4417b644ba1</type>
</return>
<return xsi:type="ns1:itemProperty">
<name xsi:type="xsd:string">name4c4417b644bdf</name>
<value xsi:type="xsd:string">value4c4417b644c1c</value>
<type xsi:type="xsd:string">type4c4417b644c59</type>
</return>
</parameters>
</ns1:getListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>