XPath and Namespace - xpath

I have the following soap response and want to extract the list of products:
<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>
<listProductsResponse xmlns="http://warehouse.acme.com/ws">
<listProductsResult>
<listProductsResult>
<productName>hammer</productName>
<productId>54112</productId>
</listProductsResult>
<listProductsResult>
<productName>drill</productName>
<productId>54113</productId>
</listProductsResult>
<listProductsResult>
<productName>circular saw</productName>
<productId>54114</productId>
</listProductsResult>
<listProductsResult>
<productName>jigsaw</productName>
<productId>54115</productId>
</listProductsResult>
</listProductsResult>
</listProductsResponse>
</soapenv:Body>
</soapenv:Envelope>
The following XPath returns a "No Match". I'm wondering why?
/soapenv:Envelope/soapenv:Body/ns:listProductsResponse
The following is working but seems to me a dirty approach since a namespace is specified for listProductsResponse:
/soapenv:Envelope/soapenv:Body/*[local-name()="listProductsResponse"]

Related

Specifying multiple ids (AlternateId ) in the ConvertId EWS request?

I was under an impression that I can pass multiple ids in the ConvertId request. If I send the following request with two ids (they happen to be folder and its child message), I only get one id back.
Sure sounds like a bug...
Request:
<?xml version="1.0" encoding="ISO-8859-1"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010"/>
</soap:Header>
<soap:Body>
<m:ConvertId DestinationFormat="EwsId">
<m:SourceIds>
<AlternateId Format="EntryId" Id="AAAAAF6BdU8APhVJsGWfKuqS58IBAMfPIwTHe/ZFheiJLdb/e6wAAAAAAQwAAA==" Mailbox="user#domain.demo"/>
<AlternateId Format="EntryId" Id="AAAAAF6BdU8APhVJsGWfKuqS58IHAMfPIwTHe/ZFheiJLdb/e6wAAAAAAQwAAEp86F7RqydMniCqPL+oKLEAAeNW8FMAAA==" Mailbox="user#domain.demo"/>
</m:SourceIds>
</m:ConvertId>
</soap:Body>
</soap:Envelope>
And the response is
<?xml version="1.0" encoding="ISO-8859-1"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" Version="V2018_01_08" MinorBuildNumber="31" MajorBuildNumber="1228" MinorVersion="20" MajorVersion="15"/>
</s:Header>
<s:Body>
<m:ConvertIdResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:ConvertIdResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:AlternateId Mailbox="user#domain.demo" Id="AQMkAGU2ZWM5ZTQwLTk0MjMtNDY3NS1iZWI5LWQ4NTA0MDhmM2U0OQBGAAADXoF1TwA+FUmwZZ8q6pLnwgcAx88jBMd79kWF6Ikt1v97rAAAAgEMAAAASnzoXtGrJ0yeIKo8v6gosQAB41bwUwAAAA==" Format="EwsId" xsi:type="t:AlternateIdType"/>
</m:ConvertIdResponseMessage>
</m:ResponseMessages>
</m:ConvertIdResponse>
</s:Body>
</s:Envelope>
EDIT:
An example of two ids (two messages) request worling as expected.
Request:
<?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>
<t:RequestServerVersion Version="Exchange2010"/>
</soap:Header>
<soap:Body>
<ConvertId xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
DestinationFormat="EwsId">
<SourceIds>
<t:AlternateId Format="EntryId"
Id="AAAAAF6BdU8APhVJsGWfKuqS58IHAMfPIwTHe/ZFheiJLdb/e6wAAAAAAQwAAEp86F7RqydMniCqPL+oKLEAAiLXM0AAAA=="
Mailbox="user#domain.demo"/>
<t:AlternateId Mailbox="user#domain.demo"
Id="AAAAAF6BdU8APhVJsGWfKuqS58IHAMfPIwTHe/ZFheiJLdb/e6wAAAAAAQwAAEp86F7RqydMniCq PL+oKLEAAiC+eEMAAA=="
Format="EntryId"/>
</SourceIds>
</ConvertId>
Response:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="20" MajorBuildNumber="1273" MinorBuildNumber="26" Version="V2018_01_08" xmlns:h="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><m:ConvertIdResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:ConvertIdResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:AlternateId xsi:type="t:AlternateIdType" Format="EwsId" Id="AQMkAGU2ZWM5ZTQwLTk0MjMtNDY3NS1iZWI5LWQ4NTA0MDhmM2U0OQBGAAADXoF1TwA+FUmwZZ8q6pLnwgcAx88jBMd79kWF6Ikt1v97rAAAAgEMAAAASnzoXtGrJ0yeIKo8v6gosQACItczQAAAAA==" Mailbox="user#domain.demo"/>
</m:ConvertIdResponseMessage>
<m:ConvertIdResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:AlternateId xsi:type="t:AlternateIdType" Format="EwsId" Id="AQMkAGU2ZWM5ZTQwLTk0MjMtNDY3NS1iZWI5LWQ4NTA0MDhmM2U0OQBGAAADXoF1TwA+FUmwZZ8q6pLnwgcAx88jBMd79kWF6Ikt1v97rAAAAgEMAAAASnzoXtGrJ0yeIKo8v6gosQACIL54QwAAAA==" Mailbox="user#domain.demo"/>
</m:ConvertIdResponseMessage>
</m:ResponseMessages>
</m:ConvertIdResponse>
</s:Body>
</s:Envelope>
Corrections
So, consolidating our exchange so it can be seen as the answer to date.
As per the sanity testing of this method by myself and Dmitry Streblechenko (the OP). In leveraging this method, multiples are allowed.
For example: only one type (messages) or another (folders) is allowed at the same time.

Get text of value of node inside SOAP body if node changes

I have a SOAP request like below
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.revenue.ie/ras/webservices">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1">
<wsse:Username>test</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">BWyAGdlqp5ZuySEwHUfniA==</wsse:Nonce>
<wsu:Created>2014-07-24T09:43:16.665Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<thisNodeChanges>
<string xsi:type="xsd:string">DATAHERE</string>
</thisNodeChanges>
</soapenv:Body>
</soapenv:Envelope>
How can i get the text value "DATAHERE" with xpath if "thisNodeChanges" changes from request to request and so does "string".
If i do //string/text()it works but it's not always called string.
Thanks
I think this could work:
'//*[name()="soapenv:Body"]/*/*/text()'

How to query EWS for a Calendar Message Body

I'm looking for a little more details than what was given in this answer: Exchange EWS not returning message body for calendar
Specifically I'm not sure how to get a calendar message's body in a query.
My XML query is:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<m:FindItem Traversal="Shallow" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Body"/>
<t:FieldURI FieldURI="calendar:Start"/>
<t:FieldURI FieldURI="calendar:End"/>
<t:FieldURI FieldURI="calendar:Location"/>
<t:FieldURI FieldURI="item:Attachments"/>
</t:AdditionalProperties>
</m:ItemShape>
<m:CalendarView EndDate="2016-07-08T00:00:00Z" MaxEntriesReturned="999999" StartDate="2016-07-07T00:00:00Z"/>
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="calendar"/>
</m:ParentFolderIds>
</m:FindItem>
</s:Body>
</s:Envelope>
But I seem to be getting an error with:
<t:FieldURI FieldURI="item:Body"/>
Error Message
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo xmlns:h="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" MajorVersion="15" MinorVersion="1" MajorBuildNumber="534" MinorBuildNumber="21"/>
</s:Header>
<s:Body>
<m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:FindItemResponseMessage ResponseClass="Error">
<m:MessageText>Property is not valid for this operation.</m:MessageText>
<m:ResponseCode>ErrorInvalidPropertyForOperation</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:MessageXml>
<t:FieldURI FieldURI="item:Body"/>
</m:MessageXml>
</m:FindItemResponseMessage>
</m:ResponseMessages>
</m:FindItemResponse>
</s:Body>
</s:Envelope>
I've looked over the API Here:
https://msdn.microsoft.com/en-us/library/office/aa494315(v=exchg.150).aspx
And I think I must be missing something simple. Is there a way using a specific field based query to get a calendar body?
Thanks
The FindItem operation doesn't return the Body, Attendees and other complex/large properties see https://blogs.msdn.microsoft.com/vikas/2007/07/26/ews-why-does-not-finditem-return-all-the-fields-you-expected/ .
So you need to take the ItemId you get from the FindItem Request and then either make a single GetItem Request https://msdn.microsoft.com/en-us/library/office/aa564509(v=exchg.150).aspx or if you need it for multiple Items batch the GetItem Request together for efficiency.

Mule:Magento connector: get-product operation bug

I am trying to get product info from magneto via magneto connector in mule USING GET-PRODUCT OPERATION, but I am getting this error: Product not existseven though tested via SOAP UI and worked perfectly.
After a long search I have found the issue:
request via SOAP UI:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header/>
<soapenv:Body>
<urn:catalogProductInfo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<sessionId xsi:type="xsd:string"/>
<productId xsi:type="xsd:string"/>
<storeView xsi:type="xsd:string"></storeView>
<attributes xsi:type="urn:catalogProductRequestAttributes">
<attributes xsi:type="urn:ArrayOfString" soapenc:arrayType="xsd:string[]">
</attributes>
<additional_attributes xsi:type="urn:ArrayOfString" soapenc:arrayType="xsd:string[]">
</additional_attributes>
</attributes>
<identifierType xsi:type="xsd:string"/>
</urn:catalogProductInfo>
</soapenv:Body>
</soapenv:Envelope>
request via magneto connector:
<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:catalogProductInfo xmlns:ns1="urn:Magento" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<sessionId xsi:type="xsd:string"></sessionId>
<product xsi:type="xsd:string"></product>
<storeView xsi:type="xsd:string" xsi:nil="true"/>
<attributes href="#id0"/>
<productIdentifierType xsi:type="xsd:string"></productIdentifierType>
</ns1:catalogProductInfo>
<multiRef xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:Magento" id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:catalogProductRequestAttributes">
<attributes soapenc:arrayType="xsd:string[1]" xsi:type="soapenc:Array">
<attributes xsi:type="xsd:string"></attributes>
</attributes>
<additional_attributes soapenc:arrayType="xsd:string[0]" xsi:type="soapenc:Array"/>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
the difference is in the <product>/<productId> tag.
Any ideas on how to fix?
Found the issue: it's in the magento_v2_soap.wsdl of the magento connector file where in the catalogProductInfoRequest the <part name="product" type="xsd:string"/>needs to be changed to <part name="productId" type="xsd:string"/> I have made the change in gitHub but I don't have write access... so what I did is I made the change downloaded and installed in mule.

Start date of recurring event is one day off?

Code block 1 below creates a recurring event, recurring every day, start date 3. May 2014
Code block 2: response OK
Code block 3: ask for first occurrence with that ID (Exchange starts counting at 1, not 0)
Code block 4: response: 1st occurrence is on 4. May ????? What is happening here (and how to fix)?
Create event:
<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:MailboxCulture>en-US</typ:MailboxCulture>
<typ:TimeZoneContext>
<typ:TimeZoneDefinition Id="W. Europe Standard Time"/>
</typ:TimeZoneContext>
</soapenv:Header>
<soapenv:Body>
<mes:CreateItem SendMeetingInvitations="SendToNone">
<mes:Items>
<typ:CalendarItem>
<typ:Subject>Random master event 24 for emp id 20652</typ:Subject>
<typ:Body BodyType="Text">TEST recurring event</typ:Body>
<typ:Categories>
<typ:String>TimeTell</typ:String>
</typ:Categories>
<typ:ReminderIsSet>false</typ:ReminderIsSet>
<typ:Start>2014-05-03T13:24:00.000+01:00</typ:Start>
<typ:End>2014-05-03T17:25:00.000+01:00</typ:End>
<typ:IsAllDayEvent>false</typ:IsAllDayEvent>
<typ:LegacyFreeBusyStatus>Busy</typ:LegacyFreeBusyStatus>
<typ:Location>Here</typ:Location>
<typ:Recurrence>
<typ:DailyRecurrence>
<typ:Interval>1</typ:Interval>
</typ:DailyRecurrence>
<typ:NumberedRecurrence>
<typ:StartDate>2014-05-03Z</typ:StartDate>
<typ:NumberOfOccurrences>27</typ:NumberOfOccurrences>
</typ:NumberedRecurrence>
</typ:Recurrence>
<typ:MeetingTimeZone TimeZoneName="W. Europe Standard Time"/>
</typ:CalendarItem>
</mes:Items>
</mes:CreateItem>
</soapenv:Body>
</soapenv:Envelope>
Response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="516" MinorBuildNumber="29" Version="Exchange2013" 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:CreateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:CreateItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:CalendarItem>
<t:ItemId Id="AAMkAG[snip]Kf/fBAAA=" ChangeKey="DwAAABYAAAC4CIO9P6hbQ7Rh7x62oA4/AACKhInU"/>
</t:CalendarItem>
</m:Items>
</m:CreateItemResponseMessage>
</m:ResponseMessages>
</m:CreateItemResponse>
</s:Body>
</s:Envelope>
Find occurrence 1:
<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:MailboxCulture>en-US</typ:MailboxCulture>
<typ:TimeZoneContext>
<typ:TimeZoneDefinition Id="W. Europe Standard Time"/>
</typ:TimeZoneContext>
</soapenv:Header>
<soapenv:Body>
<mes:GetItem>
<mes:ItemShape>
<typ:BaseShape>IdOnly</typ:BaseShape>
<typ:AdditionalProperties>
<typ:FieldURI FieldURI="calendar:Start" />
</typ:AdditionalProperties>
</mes:ItemShape>
<mes:ItemIds>
<typ:OccurrenceItemId RecurringMasterId="AAMkAG[snip]Kf/fBAAA=" InstanceIndex="1"/>
</mes:ItemIds>
</mes:GetItem>
</soapenv:Body>
</soapenv:Envelope>
Response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="516" MinorBuildNumber="29" Version="Exchange2013" 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="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Items>
<t:CalendarItem>
<t:ItemId Id="AAMkAGFkYTBkM2UxLTkyYTctNDA1NC05MGY3LWJkMzQ4MWQwNjAyMQFRAAgI0TVC7TkAAEYAAAAAhhvKZmdnRkCUOsqdWWjc9wcAuAiDvT+oW0O0Ye8etqAOPwAAAAAADwAAuAiDvT+oW0O0Ye8etqAOPwAAin/3wQAAEA==" ChangeKey="DwAAABYAAAC4CIO9P6hbQ7Rh7x62oA4/AACKhInU"/>
<t:Start>2014-05-04T12:24:00Z</t:Start>
</t:CalendarItem>
</m:Items>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
This is done with SOAPUI talking against Exchange 2013 or Exchange 2010
Here's an Outlook screen shot confirming the start at 4. May:
Additional tests:
- Creating with a NoEndRecurrence or EndDateRecurrence also fails:
<typ:NoEndRecurrence>
<typ:StartDate>2014-05-03Z</typ:StartDate>
</typ:NoEndRecurrence>
<typ:EndDateRecurrence>
<typ:StartDate>2014-05-03Z</typ:StartDate>
<typ:EndDate>2014-06-03Z</typ:EndDate>
</typ:EndDateRecurrence>
Your create call is creating the event in dd-mm-yyyZ, which is in Zulu time (a.k.a. UTC). If you're actually in a different timezone, that can skew your events by a day in either direction.
EWS and timezones (timezones in general) can be very confusing. When connecting to EWS using the Managed EWS library you can specify the Timezone you're in, that way, when you supply any dates, you don't have to constantly keep this in mind.
Also remember that certain timezones start/end their daylight savings time on different date (or don't have daylight savings at all (Arizona)). This can even move certain appointments by 1 hour in a short timewindow each year.

Resources