Am a newbie in odata4j concepts.
Using odata4j Library odata4j-0.5-nojpabundle.jar launched producer on tomcat using link
http://code.google.com/p/odata4j/wiki/Tomcat.
My producer is modified to give an large list of integers as an entity-set called "Integers"
I could retreive the serviceDoc,collection and can apply filters.
Now trying to perform post on this service doc[trying to add one more entry with same schema ].
Doing post for http://localhost:8080/OData/example.svc/Integers
with post body :
<?xml version="1.0" encoding="utf-8" ?> <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <entry> <id>http://localhost:8080/OData/example.svc/Integers(100)</id>
<title type="text" />
<updated>2011-12-29T10:50:33Z</updated>
<author> <name /> </author>
<link rel="edit" title="Integers" href="Integers(100)" />
<category term="example.Integers" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:EntityId m:type="Edm.Int32">100</d:EntityId> </m:properties>
</content>
</entry>
am getting 406 not Acceptable Unknown content type application/xml;charset=UTF-8.
Int collection content type is application/xml. Still not able to find out why is this response is obtained.
Does anyone know what i am missing here.
Thanks in Advance.
Use application/atom+xml as the Content-Type
Entry should be the document element (your xml above is not well-formed)
See: http://www.odata.org/developers/protocols/operations#CreatingnewEntries
Hope that helps,
- john
Related
I'm rewriting C# application into java code.
There is REST API which return jsons.
I have to parse json to XML but C# library and Java doing it in difference ways.
How to keep type= attribute in java? I can't use JAXB annotations becouse there are too many objects in response and they might changing. XML.toString(jsonObject) doesn't work for me.
C# parsing is done in this way:
XDocument.load(JsonReaderWriterFactory.CreateJsonReader(Encoding.ASCII.GetBytes(jsonString), new XmlDictionaryReaderQuotas()));
C# result:
<root type="object">
<Items type="array">
<item type="object">
<Name type="string">test</Name>
<Total type="number">12.8000000</Total>
<CurrencyCode type="string">CHF</CurrencyCode>
<Country type="string">CH</Country>
</item>
</Items>
</root>
Java result:
<root>
<Items>
<item>
<Name>test</Name>
<Total>12.8000000</Total>
<CurrencyCode>CHF</CurrencyCode>
<Country>CH</Country>>
</item>
</Items>
</root>
I've used org.w3c.Document and org.w3c.dom.Element and set up attribute "type".
Anyway thanks for help :)
I am getting following exception while parsing XML
org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
SOAp Request i am sending:
<soap:Envelope>
<soap:Header/>
<soap:Body>
<ver:ReceiveOnlineBatchExternalAttachment>
<web:username>user</web:username>
<web:passwd>pass</web:passwd>
<web:receiversReference>1232323</web:receiversReference>
<web:sequenceNumber>1</web:sequenceNumber>
<web:batch>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<DataBatch>
<DataUnits>
<DataUnit>
<FormTask>
<ServiceCode>323015</ServiceCode>
<Form>
<FormData>
<![CDATA[<melding> </melding>]]
</FormData>
</Form>
</FormTask>
</DataUnit>
</DataUnits>
</DataBatch>
]]>>
</web:batch>
</ver:ReceiveOnlineBatchExternalAttachment>
</soap:Body>
</soap:Envelope>
I have done changes to CDATA multiple times but getting same error.
Could anyone suggest how CDATA within CDATA can be handled in this request?
Tried following but failed:
<![CDATA[ <elements> <![CDATA[<melding> </melding>]] <elements> ]]>>
<![CDATA[ <elements> <![CDATA[<melding> </melding>]]> <elements> ]]>
<![CDATA[ <elements> <![CDATA[<melding> </melding>]]> <elements> ]]>
I speculate that your problem is actually being caused by nested CDATA content. Can you try the following:
<![CDATA[
<DataBatch>
<DataUnits>
<DataUnit>
<FormTask>
<ServiceCode>323015</ServiceCode>
<Form>
<FormData>
<![CDATA[
<melding> </melding>
]]]]><![CDATA[>
</FormData>
</Form>
</FormTask>
</DataUnit>
</DataUnits>
</DataBatch>
]]>
The gist of the trick here is that when the parser hits the inner nested <![CDATA[ it will actually ignore it. Then, when it hits this:
]]]]><![CDATA[>
the first ]] will also be ignored, the following ]]> will be consumed, closing the outer CDATA, and then a new CDATA is immediately opened again which should last until the outer closing for that.
Edit by #fatherazrael:
Remove the XML tags <?xml version="1.0" encoding="UTF-8"?>
Reference: Nested CDATA - correctly
I am using the following query to retrieve the Changeset.
OSCL Query:
https://ibm.com:9443/ccm/resource/itemOid/com.ibm.team.scm.ChangeSet/_HFxrmiEbEeS7m-qENunxUw?_mediaType=text/xml
Getting the following response:
<scm:ChangeSet itemId="_HFxrmiEbEeS7m-qENunxUw"
properties="">
<stateId>_W8aNECEbEeS7m-qENunxUw</stateId>
<immutable>true</immutable>
<contextId>_Dp6kMdwTEd2jUupDpQV1Rw</contextId>
<modified>2014-08-11T05:50:11.568Z</modified>
<mergePredecessor xsi:nil="true" />
<predecessor>_RaxwgCEbEeS7m-qENunxUw</predecessor>
<active>false</active>
<comment>Test</comment>
<lastUpdatedDate>2014-08-11T05:50:11.225Z</lastUpdatedDate>
<modifiedBy itemId="_FAv8gA4GEeSsZdvBzERdWQ" />
<changes>
<internalId>_HUW6IiEbEeS7m-qENunxUw</internalId>
<kind>2</kind>
<before>_nDuHQBhzEeS88s3Rov8pNA</before>
<after>_HUNJJSEbEeS7m-qENunxUw</after>
<item itemId="_k5S2oBhzEeSht4FX-gq3Zg" xsi:type="filesystem:FileItemHandle" />
</changes>
<component itemId="_RvxoEBhzEeS88s3Rov8pNA" />
<owner itemId="_FAv8gA4GEeSsZdvBzERdWQ" />
<xComponentLink xsi:nil="true" />
I would like to get the Changes detail. It would be great if someone shares the OSLC
query to retrieve Changes details.
#user2530633, try the below query, it is not oslc query
.com/ccm/service/com.ibm.team.filesystem.common.internal.rest.IFilesystemRestService2/changeSetPlus?knownTextContentTypePrefixes=text%2F&knownTextContentTypeStrings=application%2Fxml&knownTextContentTypeStrings=application%2Fjavascript&knownTextContentTypeStrings=application%2Fecmascript&knownTextContentTypeStrings=application%2Fx-javascript&changeSetPath=workspaceId%2F_Dh7kMAHIEeSZzL8CZgHcOQ%2FchangeSetId%2F_quVzDljgEeSiBMylK1kVWg&maxChanges=500"
here just replace your workspaceid and changesetid you can find the changes with the content
I'm new to mule and working on a POC. I want to enrich the payload(target.xml) by calling an http endpoint which returns xml as response (source.xml) .
<flow name="mule-configFlow" doc:name="mule-configFlow">
<jms:inbound-endpoint doc:name="JMS" connector-ref="Active_MQ" queue="QUEUE1"/>
<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
<enricher doc:name="Message Enricher" target="#[xpath:Customer/OfficeId]">
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8095" path="myservice/v1/" method="GET" doc:name="HTTP">
<expression-transformer evaluator="xpath" expression="Response/OffId" />
</http:outbound-endpoint>
</enricher>
<jms:outbound-endpoint queue="QUEUE2" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
I've verified and http endpoint works fine but I'm getting the below error
Expression Evaluator "xpath" with expression "Response/OffId" returned null but a value was required
Am i configuring the source and target expression correctly ?
Incoming Message payload (target.xml):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Customer xmlns="http://www.xyz.com/abc/v1">
<ActionType>ACCOUNT_ADDED</ActionType>
<OfficeId></OfficeId>
<MemberId></MemberId>
</Customer>
Source for enrichment (source.xml):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response xmlns="http://www.xyz.com/abc/v1">
<OffId></OffId>
<MemId></MemId>
</Response>
There's a couple of issues here:
your expression transformer will not work inside the outbound endpoint
your xpath expression will not work due to the xmlns ref in the xml
you can not transform an xml string with an enhancer
To make this work, put the outbound endpoint and the expression transporter inside a process-chain, use an xpath expression that either handles namespaces or ignores them, and transform your initial xml string payload to something else, for example DOM, that you can manipulate.
Something like this should work:
<mulexml:xml-to-dom-transformer returnClass="org.dom4j.Document"/>
<enricher source="#[payload]" target="#[payload.rootElement.element('OfficeId').text]">
<processor-chain>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8095" path="myservice/v1/" method="GET"/>
<expression-transformer evaluator="xpath" expression="//*[local-name()='OffId']" />
</processor-chain>
</enricher>
Here is my xml file:
<User xmlns="http://schemas.datacontract.org/2004/07/IntranetEFCodeFirst.Objects" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<CostCentre i:nil="true"/>
<DeskNo i:nil="true"/>
<Domain>MyDomain</Domain>
<Email>marco#beirut.co.uk</Email>
<Extension>2354</Extension>
<FirstName>Marco</FirstName>
<KnownAs>Marco l'ancien</KnownAs>
</User>
If I do this:
<c:import url="http://mydomain.co.uk/myFile.xml" var="xmlDoc"/>
<x:parse xml="${xmlDoc}" var="output"/>
<x:out select="$output" />
It returns:
MyDomainmarco#beirut.co.uk2354MarcowankerMarco l'ancien
I want to display a node-specific content using
<c:import url="http://mydomain.co.uk/myFile.xml" var="xmlDoc"/>
<x:parse xml="${xmlDoc}" var="output"/>
<x:out select="$output/User/FirstName" />
<x:out select="$output/User/Email" />
But it returns nothing.
Any idea what's going wrong?
You are probably experiencing namespace problems. Try a document without a namespace and see if this works.
Thanks Michael'O, the issue did come from the XML document itself.
I changed the XML doc to the following and it worked fine
<?xml version="1.0" encoding="ISO-8859-1"?>
<User>
<Domain>MyDomain</Domain>
<Email>marco#beirut.co.uk</Email>
<Extension>2354</Extension>
<FirstName>Marco</FirstName>
<KnownAs>Marco l'ancien</KnownAs>
</User>