I have a webapi controller that returns an Items object like:
<Items>
<Item>
<Color>PINK</Color>
<CommercialProductBundle>NOTAPPLICABLE</CommercialProductBundle>
<Descriptions/>
</Item>
<Item>
<Color>Black</Color>
<CommercialProductBundle>NOTAPPLICABLE</CommercialProductBundle>
<Descriptions/>
</Item>
</Items>
In order to use ODATA query functionality I changed the return type from
public Items GetAllItems()
where Items is 'List' to
IQueryable GetAllItems() .
But then my response shows in stead of :
<ArrayOfItem xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Item>
<Color>PINK</Color>
<CommercialProductBundle>NOTAPPLICABLE</CommercialProductBundle>
<Descriptions/>
</Item>
<Item>
<Color>Black</Color>
<CommercialProductBundle>NOTAPPLICABLE</CommercialProductBundle>
<Descriptions/>
</Item>
</ArrayOfItem>
Is there a way to get rid of the 'ArrayOf', showing again the initial xml?
Thanks for any help.
Have you let your controller derive from ODataController? Have you installed the ASP.NET Web API OData V1-3 assemblies? Have you modified your WebApiConfig.cs to map the OData route?
As OData queryability depends on its unique routing convention and the Web API configuration, you might want to follow this tutorial to http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v3/creating-an-odata-endpoint and implement accordingly for getting this querability.
Related
Given a DataMapper node that would map between the following two structures:
Strcuture A:
<item>
<id>123</id>
<price>1</price>
<quantity>1</quantity>
</item>
<item>
<id>124</id>
<price>2</price>
<quantity>1</quantity>
</item>
<item>
<id>125</id>
<price>3</price>
<quantity>1</quantity>
</item>
Structure B:
<total>
<totalPrice>6</totalPrice>
</total>
The Mule ESB DataMapper will generate a CTL2 (Clover) Transformation.
Can the Mule ESB DataMapper also generate XSLT
Do you mean to perform a XML transformation? Because if this is the case then yes.
If what you mean is to generate XSLT, technically I can, but makes no sense as XSLT is not meant to contain information but rather to transform it.
I guess XSLT (Extensible Stylesheet Language Transformations) is a language for transforming XML documents into other XML documents and I am afraid Data mapper cannot generate a XSLT ...
you can always use Mule XSLT transformer separately to transform data into your expected format of XML:- http://www.mulesoft.org/documentation/display/current/XSLT+Transformer
You can use XSLT component and provide an xsl file. This xsl file would be convert between 2 different sml formats.
Below is the example of mule flow for the same.
<file:connector name="File" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="xsltexampleFlow">
<file:inbound-endpoint path="D:\Mule_Work\Input" connector-ref="File" responseTimeout="10000" doc:name="File"/>
<logger message="------------------File Read------------" level="INFO" doc:name="Logger"/>
<mulexml:xslt-transformer xsl-file="D:\Mule_Work\Output\transform.xsl" maxIdleTransformers="2" maxActiveTransformers="5" doc:name="XSLT"/>
<logger level="INFO" doc:name="Logger" message="--------------XSL Transformation---------------------"/>
<file:outbound-endpoint path="D:\Mule_Work\Output" outputPattern="Output_transform.xml" connector-ref="File" responseTimeout="10000" doc:name="File"/>
</flow>
I'm developing a backend that should accept JSON objects and input them in the datastore if they meet certain criteria. My problem is that i get crippled content when i send json that has unicode letters . I have tried it with both the api explorer and rest client plugin for Firefox
my endpoint API method looks like this:
#ApiMethod(name = "addObj", httpMethod = "post" , path = "addObj")
public ArtObj addObj(ArtObj obj)
throws OAuthRequestException, IOException,IllegalArgumentException
{
}
and my Json looks like the following
{
someText:"محتوى عربى",
someEnglish : "English content"
}
According to many articles i did add this in my appengine-web.xml
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
<property name="file.encoding" value="UTF-8" />
<property name="DEFAULT_ENCODING" value="UTF-8" />
</system-properties>
but all i receive is a parsed POJO but with garbled unicode letters and perfect english .
I've found an answer to my question . I'm using windows and so the environment variable
JAVA_TOOL_OPTIONS has to be set to -Dfile.encoding=UTF8 to set the default encoding for the JVM . now i get correct JSON .
Thanks
I face the same problem to insert entity in Thai, my solutions is to open project properties window on Eclipse, under "Resource/Text file encoding" click "Other" and select "UTF-8" and it's work.
I have a question about creation of an RSS feed.
I have read a few different bits of information on creation of an RSS feed and this, on the whole doesn't appear too difficult.
What I'm struggling to understand though is how to automatically populate the RSS feed xml file?
Here is our basic .xml file...
<?xml version='1.0' encoding='utf-8'?>
<rss version='2.0'>
<channel>
<title>Channel Title</title>
<description>Description of Channel</description>
<link>http://www.test.com</link>
<item>
<title>Item Title</title>
<description>Updated on: 5/20/2012</description>
<link>http://www.test.com/itempage.asp?itemID=1</link>
</item>
</channel>
</rss>
We can, obviously, manually enter each item but I want this to automatically select the latest items from our database. In this case, news items.
you can use the Msxml2.DOMDocument.6.0 object. have a look here for MSXML DOM Reference.
with that object you can create xml nodes and then save the xml document...
example:
set xml = server.createobject("Msxml2.DOMDocument.6.0")
set rssNode = xml.createElement("rss")
rssNode.appendChild(xml.createTextNode(""))
rssNode.setAttribute "version", "2.0"
i m trying to insert new item on sharepoint list from flex using sharepoint-as3-connector (http://code.google.com/p/sharepoint-as3-connector). but i m getting following error.
Response XML:<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>
<UpdateListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<UpdateListItemsResult>
<Results>
<Result ID="1,UpdateList.NEW">
<ErrorCode>0x8102000a</ErrorCode>
<ErrorText>Invalid URL Parameter
The URL provided contains an invalid Command or Value. Please check the URL again.
below is the header made in soap URL.
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>
TestList
</listName>
<updates>
<Batch OnError="Continue">
<Method ID="1" Cmd="UpdateList.NEW">
<Field Name="ows_LinkTitle">
222222
</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
please help!
The error message is spot on: you are specifying an invalid command in the Cmd attribute of the Method element.
Per the MSDN article for the Method element, valid values for Cmd are:
Delete
New
Update
I have no experience with the "sharepoint-as3-connector", and I suppose it's there to make your life easier. But it's probably worth reviewing the MSDN documentation for the Lists web service (and specifically the UpdateListItems method) so you know what SharePoint is expecting. SharePoint is a delicate flower that cannot be handled harshly; you must know exactly what it wants to keep it happy.
A good walkthrough on MSDN: How to: Update List Items.
I have a table defnition as given below:
License
ClientId
Type
Total
Used
ClientId and Type together uniquely identifies a row. I have a mapping file as given below:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="Acumen.AAM.Domain.Model.License, Acumen.AAM.Domain" lazy="false" table="License">
<id name="ClientId" access="field" column="ClientID" />
<property name="Total" access="field" column="Total"/>
<property name="Used" access="field" column="Used"/>
<property name="Type" access="field" column="Type"/>
</class>
</hibernate-mapping>
If a client used a license to create a user, I need to update the Used column in the table. As I set ClientId column as the id column for this table in the mapping xml, I am getting TooManyRowsAffectedException.
could you please let me know how to set a composite key at mapping level so that NHibernate can udpate based on ClientId and Type.
Something like: Update License SET Used=Used-1 WHERE ClientId='xxx' AND Type=1
Please help.
Thanks,
Mahesh
You have to use a composite-id
http://nhibernate.info/doc/nh/en/index.html#mapping-declaration-compositeid
If you primary key is composite, your mapping should reflect that, and your class needs to override Equals and GetHashCode.
Also, if ClientId is the primary key of your Client entity, you should map it as many-to-many, not just an Id.
Also, why are you specifying lazy="false"? Are you aware of the implications?
Also, why map everything with access="field"? Do the properties have some special logic?
This is a revised mapping considering everything I just wrote. Feel free to ignore those parts that don't apply :-)
<class name="Acumen.AAM.Domain.Model.License, Acumen.AAM.Domain" table="License">
<composite-id>
<key-many-to-one name="Client" column="ClientID" />
<key-property name="Type" />
</composite-id>
<property name="Total" />
<property name="Used" />
</class>
As the other comrades mentioned above, you have to use a composite-id, which is not a best but acceptable practice.
On the other hand, you can simply write an update interceptor and make sure your Type = 1 within it.
Here are some link about the topic to help you see clear in this.
Elegant code : Implementing NHibernate Interceptors
NHibernate Documentation : Interceptors
Sample NHibernate IInterceptor implementation
Enterprise .NET Community : NHibernate Part 2 (Scroll down to : Interceptors and Persistent Lifecycle)
NHibernate Interceptor Auditing Inserted Object Id (SO question)
The main advantage of using interceptors over a composite key is that it doesn't break your DBRM and provides a definitely more flexible solution, without "polluting" your mapping file which will more precisely represent your model.