Getting issue in making JSON request from xml request of SAP - json

My Requirement is to create a JSON for the below xml, and send as POST request to SAPNetweaver adapter.
SAP End point
URI: /sap/opu/odata/sap/ZPM_MOBILE_SRV/WOHeaderSet
Method: POST
Payload: 1 operation, 2 materials
XML request which contain two payload operations and material.
1. operation : WOHeaderOperation
2. materail : WOHeaderMaterial
this code basically contain two section one WOHeaderOperation and second for WOHeaderMaterial
<?xml version="1.0" encoding="UTF-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<atom:content type="application/xml">
<m:properties>
<d:Aufpl>1000000053</d:Aufpl>
<d:GltrpTms>1425887760</d:GltrpTms>
<d:GstrpTms>1425887760</d:GstrpTms>
<d:Auart>PM02</d:Auart>
<d:Ktext>Test for MAMBO 2</d:Ktext>
<d:Iwerk>KACT</d:Iwerk>
<d:Ingrp>KP</d:Ingrp>
<d:Gewrk>10000359</d:Gewrk>
<d:Tplnr>KAC-0P5010-PM1</d:Tplnr>
<d:Arbpl>10000359</d:Arbpl>
</m:properties>
</atom:content>
<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/WOHeaderOperation" type="application/atom+xml;type=feed" title="WOHeaderOperation">
<m:inline>
<atom:feed>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:Vornr>0010</d:Vornr>
<d:Ltxa1>Operation 1</d:Ltxa1>
<d:Indet>2</d:Indet>
</m:properties>
</atom:content>
</atom:entry>
</atom:feed>
</m:inline>
</atom:link>
<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/WOHeaderMaterial" type="application/atom+xml;type=feed" title="WOHeaderMaterial">
<m:inline>
<atom:feed>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:Vornr>0010</d:Vornr>
<d:Posnr>0010</d:Posnr>
<d:Matnr>340</d:Matnr>
<d:Werks>KACT</d:Werks>
<d:Bdmng>7.000</d:Bdmng>
<d:Meins>PCE</d:Meins>
<d:Postp>L</d:Postp>
</m:properties>
</atom:content>
</atom:entry>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:Vornr>0010</d:Vornr>
<d:Posnr>0020</d:Posnr>
<d:Matnr>338</d:Matnr>
<d:Werks>KACT</d:Werks>
<d:Bdmng>10.000</d:Bdmng>
<d:Meins>PCE</d:Meins>
<d:Postp>L</d:Postp>
</m:properties>
</atom:content>
</atom:entry>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:Vornr>0010</d:Vornr>
<d:Posnr>0030</d:Posnr>
<d:Matnr>336</d:Matnr>
<d:Werks>KACT</d:Werks>
<d:Bdmng>10.000</d:Bdmng>
<d:Meins>PCE</d:Meins>
<d:Postp>L</d:Postp>
</m:properties>
</atom:content>
</atom:entry>
</atom:feed>
</m:inline>
</atom:link>
</atom:entry>

If you want it to be JSON, request it as such:
GET /sap/opu/odata/sap/ZPM_MOBILE_SRV/WOHeaderSet?$format=json
But Gateway will accept both JSON and XML so there is really no need other than your own preference.

Related

How to extract this XML Objects with XSLT

I want to extract the JSONx Data from a XML File to transform in JSON. So i need to extract the json:object from this File
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/ envelope/">
<soapenv:Body>
<json:object xmlns:json="http://www.ibm.com/xmlns/prod/2009/
jsonx" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xsi:schemaLocation="http://www.datapower.com/ schemas/json jsonx.xsd">
<json:string name="Number">XXX</json :string>
<json:string name="name">XXX</json:string> <json:string name="Date">4/84</json:string> <json:string name="amount">123</json:string>
</json:object> </soapenv:Body>
</soapenv:Envelope>
the result should look like this
<json:object xmlns:json="http://www.ibm.com/xmlns/prod/2009/
jsonx" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xsi:schemaLocation="http://www.datapower.com/ schemas/json jsonx.xsd">
<json:string name="Number">XXX</json :string>
<json:string name="name">XXX</json:string> <json:string name="Date">4/84</json:string> <json:string name="amount">1234</json:string>
</json:object>
Assuming XSLT 2.0 you can use xsl:copy-of and copy-namespaces="no" to exclude the SOAP namespace:
<xsl:template match="/">
<xsl:copy-of select="//object" xpath-default-namespace="http://www.ibm.com/xmlns/prod/2009/jsonx" copy-namespaces="no"/>
</xsl:template>

EWS operation to edit Distribution list

I am looking for an EWS operation to edit a Distribution list. Here edit means, adding\deleting a existing contact into\from an existing group or changing Display Name of Group.
I have tried option like mentioned in following link:- https://social.msdn.microsoft.com/Forums/office/en-US/db110c4e-a0f2-40de-9276-3e30458b254f/ews-maximum-number-of-members-in-a-contact-group?forum=exchangesvrdevelopment
Also used properties like AppendToItemField, SetItemField and DeleteItemField?But error comes as "The method or operation is not implemented"
Finally i got the answer for Editing Groups. here is SOAP call which worked for me:-
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<RequestServerVersion Version="Exchange2013" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap:Header>
<soap:Body>
<UpdateItem ConflictResolution="AutoResolve" MessageDisposition="SaveOnly" SendMeetingInvitationsOrCancellations="SendToNone" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemChanges>
<t:ItemChange>
<t:ItemId Id="AAMkADZmMjJlMDk...." ChangeKey="EgAAAB..." />
<t:Updates>
<t:AppendToItemField>
<t:FieldURI FieldURI="distributionlist:Members" />
<t:DistributionList>
<t:Members>
<t:Member>
<t:Mailbox>
<t:ItemId Id="AAMkADZmMjJ..." ChangeKey="EQAAABYA..." />
</t:Mailbox>
</t:Member>
<t:Member>
<t:Mailbox>
<t:EmailAddress>user#contonso.com</t:EmailAddress>
</t:Mailbox>
</t:Member>
</t:Members>
</t:DistributionList>
</t:AppendToItemField>
</t:Updates>
</t:ItemChange>
</ItemChanges>
</UpdateItem>
</soap:Body>
</soap:Envelope>

How to find whether an appointment exists by ApointmentId

I used Appointment.Bind() & pass in ApointmentId. If it exists it return all the details about the appointment, if not it doesn't throw any exception but gives some appointment object.
I want to how to figure out if appointment exists or not?
If the ID represents an item that's not there, you should get a ServiceResponseException with the message The specified object was not found in the store. The SOAP response looks like this:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="1" MajorBuildNumber="207" MinorBuildNumber="19" Version="V2_47" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:GetItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Error">
<m:MessageText>The specified object was not found in the store.</m:MessageText>
<m:ResponseCode>ErrorItemNotFound</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Items />
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>

ExchangeEWS throws ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange when I'm trying to get an existing occurence by index

I have the strange situation:
I created recurring calendar event by Exchange web service using the request like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types">
<soapenv:Header>
<typ:RequestServerVersion Version="Exchange2007_SP1"/>
<typ:ExchangeImpersonation>
<typ:ConnectingSID>
<typ:PrimarySmtpAddress>someuser#clab.local</typ:PrimarySmtpAddress>
</typ:ConnectingSID>
</typ:ExchangeImpersonation>
</soapenv:Header>
<soapenv:Body>
<mes:CreateItem MessageDisposition="SaveOnly" SendMeetingInvitations="SendToAllAndSaveCopy">
<mes:Items>
<typ:CalendarItem>
<typ:Subject>QC42135 test 3</typ:Subject>
<typ:Body BodyType="HTML"/>
<typ:Importance>Normal</typ:Importance>
<typ:ReminderIsSet>false</typ:ReminderIsSet>
<typ:Start>2014-07-25T04:00:00-05:00</typ:Start>
<typ:End>2014-07-25T05:00:00-05:00</typ:End>
<typ:Location/>
<typ:IsResponseRequested>false</typ:IsResponseRequested>
<typ:RequiredAttendees>
<typ:Attendee>
<typ:Mailbox>
<typ:EmailAddress>user1#clab.local</typ:EmailAddress>
</typ:Mailbox>
</typ:Attendee>
</typ:RequiredAttendees>
<typ:Recurrence>
<typ:WeeklyRecurrence>
<typ:Interval>2</typ:Interval>
<typ:DaysOfWeek>Wednesday Thursday Friday Saturday Sunday</typ:DaysOfWeek>
</typ:WeeklyRecurrence>
<typ:EndDateRecurrence>
<typ:StartDate>2014-07-20</typ:StartDate>
<typ:EndDate>2014-07-30</typ:EndDate>
</typ:EndDateRecurrence>
</typ:Recurrence>
<typ:MeetingTimeZone TimeZoneName="FLE Standard Time"/>
</typ:CalendarItem>
</mes:Items>
</mes:CreateItem>
</soapenv:Body>
</soapenv:Envelope>
Series of occurences were successfully created:
<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:Header>
<t:ServerVersionInfo MajorVersion="8" MinorVersion="3" MajorBuildNumber="348" MinorBuildNumber="2" Version="Exchange2007_SP1" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"/>
</soap:Header>
<soap:Body>
<m:CreateItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:CreateItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:CalendarItem>
<t:ItemId Id="AAMkADVmYWI5YjhjLTdiN2MtNDJjNi04ZWIzLTUzNjVjZjk1MWY5OQBGAAAAAACuKk855hnzQ7gDOBltDFd1BwAa27cU8ukoS5yPRueWn38YAAobNHU+AAAa27cU8ukoS5yPRueWn38YAHDq5rCGAAA=" ChangeKey="DwAAABYAAAAa27cU8ukoS5yPRueWn38YAHDq52bj"/>
</t:CalendarItem>
</m:Items>
</m:CreateItemResponseMessage>
</m:ResponseMessages>
</m:CreateItemResponse>
</soap:Body>
</soap:Envelope>
But when I'm trying to get occurrences of the event
by index right after creation I'm able to get only first occurrence. For the others I receive ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange.
Here is GetItem request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages">
<soapenv:Header><typ:RequestServerVersion Version="Exchange2007_SP1"/>
<typ:ExchangeImpersonation>
<typ:ConnectingSID>
<typ:PrimarySmtpAddress>someuser#clab.local</typ:PrimarySmtpAddress>
</typ:ConnectingSID>
</typ:ExchangeImpersonation>
</soapenv:Header>
<soapenv:Body>
<mes:GetItem>
<mes:ItemShape>
<typ:BaseShape>IdOnly</typ:BaseShape>
</mes:ItemShape>
<mes:ItemIds>
<typ:OccurrenceItemId RecurringMasterId="AAMkADVmYWI5YjhjLTdiN2MtNDJjNi04ZWIzLTUzNjVjZjk1MWY5OQBGAAAAAACuKk855hnzQ7gDOBltDFd1BwAa27cU8ukoS5yPRueWn38YAAobNHU+AAAa27cU8ukoS5yPRueWn38YAHDq5rCGAAA=" ChangeKey="DwAAABYAAAAa27cU8ukoS5yPRueWn38YAHDq52bj" InstanceIndex="1" />
<typ:OccurrenceItemId RecurringMasterId="AAMkADVmYWI5YjhjLTdiN2MtNDJjNi04ZWIzLTUzNjVjZjk1MWY5OQBGAAAAAACuKk855hnzQ7gDOBltDFd1BwAa27cU8ukoS5yPRueWn38YAAobNHU+AAAa27cU8ukoS5yPRueWn38YAHDq5rCGAAA=" ChangeKey="DwAAABYAAAAa27cU8ukoS5yPRueWn38YAHDq52bj" InstanceIndex="2" />
<typ:OccurrenceItemId RecurringMasterId="AAMkADVmYWI5YjhjLTdiN2MtNDJjNi04ZWIzLTUzNjVjZjk1MWY5OQBGAAAAAACuKk855hnzQ7gDOBltDFd1BwAa27cU8ukoS5yPRueWn38YAAobNHU+AAAa27cU8ukoS5yPRueWn38YAHDq5rCGAAA=" ChangeKey="DwAAABYAAAAa27cU8ukoS5yPRueWn38YAHDq52bj" InstanceIndex="3" />
<typ:OccurrenceItemId RecurringMasterId="AAMkADVmYWI5YjhjLTdiN2MtNDJjNi04ZWIzLTUzNjVjZjk1MWY5OQBGAAAAAACuKk855hnzQ7gDOBltDFd1BwAa27cU8ukoS5yPRueWn38YAAobNHU+AAAa27cU8ukoS5yPRueWn38YAHDq5rCGAAA=" ChangeKey="DwAAABYAAAAa27cU8ukoS5yPRueWn38YAHDq52bj" InstanceIndex="4" />
<typ:OccurrenceItemId RecurringMasterId="AAMkADVmYWI5YjhjLTdiN2MtNDJjNi04ZWIzLTUzNjVjZjk1MWY5OQBGAAAAAACuKk855hnzQ7gDOBltDFd1BwAa27cU8ukoS5yPRueWn38YAAobNHU+AAAa27cU8ukoS5yPRueWn38YAHDq5rCGAAA=" ChangeKey="DwAAABYAAAAa27cU8ukoS5yPRueWn38YAHDq52bj" InstanceIndex="5" />
</mes:ItemIds>
</mes:GetItem>
</soapenv:Body>
</soapenv:Envelope>
And response
<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:Header>
<t:ServerVersionInfo MajorVersion="8" MinorVersion="3" MajorBuildNumber="348" MinorBuildNumber="2" Version="Exchange2007_SP1" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"/>
</soap:Header>
<soap:Body>
<m:GetItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:CalendarItem>
<t:ItemId Id="AAMkADVmYWI5YjhjLTdiN2MtNDJjNi04ZWIzLTUzNjVjZjk1MWY5OQFRAAiI0XGjJ/YgAEYAAAAAripPOeYZ80O4AzgZbQxXdQcAGtu3FPLpKEucj0bnlp9/GAAKGzR1PgAAGtu3FPLpKEucj0bnlp9/GABw6uawhgAAEA==" ChangeKey="DwAAABYAAAAa27cU8ukoS5yPRueWn38YAHDq52bj"/>
</t:CalendarItem>
</m:Items>
</m:GetItemResponseMessage>
<m:GetItemResponseMessage ResponseClass="Error">
<m:MessageText>Occurrence index is out of recurrence range.</m:MessageText>
<m:ResponseCode>ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Items/>
</m:GetItemResponseMessage>
<m:GetItemResponseMessage ResponseClass="Error">
<m:MessageText>Occurrence index is out of recurrence range.</m:MessageText>
<m:ResponseCode>ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Items/>
</m:GetItemResponseMessage>
<m:GetItemResponseMessage ResponseClass="Error">
<m:MessageText>Occurrence index is out of recurrence range.</m:MessageText>
<m:ResponseCode>ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Items/>
</m:GetItemResponseMessage>
<m:GetItemResponseMessage ResponseClass="Error">
<m:MessageText>Occurrence index is out of recurrence range.</m:MessageText>
<m:ResponseCode>ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Items/>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</soap:Body>
</soap:Envelope>
I found the description of recurring event on Microsoft site http://msdn.microsoft.com/en-us/library/office/dd633684%28v=exchg.80%29.aspx
and according the documentation when a recurring series is created, each occurrence item has as index that represents its position in the series.
The index starts at one and advances by one for each item in the series. But it seems to be incorrect.
In my case obviously occurrences are indexed in different way.
Can anyone explain how Exchange indexes occurrences? How can I get certain occurrence in the series?

Google Apps Script-How to get value from XmlDocument?

I am trying to get all calender details of all users. I got this successfully but its return result in Xml format as following:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>http://www.google.com/calendar/feeds/email-id/private/full</id>
<updated>2012-02-15T15:34:49.000Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/>
<title type="text">email-id</title>
<subtitle type="text">email-id</subtitle>
<link href="https://www.google.com/calendar/embed?src=email-id" rel="alternate" type="text/html"/>
<link href="https://www.google.com/calendar/feeds/email-id/private/full" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
<link href="https://www.google.com/calendar/feeds/email-id/private/full" rel="http://schemas.google.com/g/2005#post" type="application/atom+xml"/>
<link href="https://www.google.com/calendar/feeds/email-id/private/full/batch" rel="http://schemas.google.com/g/2005#batch" type="application/atom+xml"/>
<link href="https://www.google.com/calendar/feeds/email-id/private/full?max-results=25" rel="self" type="application/atom+xml"/>
<author>
<name>Name</name>
<email>email-id</email>
</author>
<generator uri="http://www.google.com/calendar" version="1.0">Google Calendar</generator>
<openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:totalResults>
<openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex>
<openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage>
<gCal:timezone value="Europe/Dublin" xmlns:gCal="http://schemas.google.com/gCal/2005"/>
<gCal:timesCleaned value="0" xmlns:gCal="http://schemas.google.com/gCal/2005"/>
<entry>
<id>http://www.google.com/calendar/feeds/email-id/private/full/vj39u2qedgphrp10nah92h6ho0</id>
<published>2012-02-15T11:21:54.000Z</published>
<updated>2012-02-15T11:21:54.000Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/>
<title type="text">Test Appointment</title>
<content type="text">This is a test description</content>
<link href="https://www.google.com/calendar/event?eid=dmozOXUycWVkZ3BocnAxMG5haDkyaDZobzAgcmFoaW1AZGFtc2" rel="alternate" title="alternate" type="text/html"/>
...
</entry>
</feed>
I want to get the value of title and content.Please share me with the solution
Thank you
Use the built-in Xml service https://developers.google.com/apps-script/service_xml.
With this sevice you can parse thru the xml document.