Parse Soap Response XML using Spring Batch - soap

How can I parse the SOAP response xml using Spring Batch. Creating bean for org.springframework.batch.item.xml.StaxEventItemReader and passring fragmentRootElementName parameter value as XMLData returned nothing, probably unmarshalling issue.
SOAP XML
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<WSCorIDSOAPHeader xmlns="http://www.wilytech.com/" CorID="5A35F9B79906411A00156F9B91FFE1EB,1:1,0,0,wl-flor-apvm106|Tomcat|dorms106-1|WebServices|Client|http_//tempuri.org/|submit,2,AgAAAdRIQgAAAAFGAAAAAQAAABFqYXZhLnV0aWwuSGFzaE1hcAAAAAdIQgAAAAJGAAAAAgAAABBqYXZhLmxhbmcuU3RyaW5nABBBcHBNYXBDYWxsZXJUeXBlSEIAAAADRQAAAAIACldlYlNlcnZpY2VIQgAAAARFAAAAAgARQXBwTWFwQ2FsbGVyQWdlbnRIQgAAAAVFAAAAAgAKZG9ybXMxMDYtMUhCAAAABkUAAAACAA9DYWxsZXJUaW1lc3RhbXBIQgAAAAdFAAAAAgANMTQ1NzUwNzQwMDExOUhCAAAACEUAAAACABZBcHBNYXBDYWxsZXJNZXRob2ROYW1lSEIAAAAJRQAAAAIAGmh0dHBfLy90ZW1wdXJpLm9yZy98c3VibWl0SEIAAAAKRQAAAAIAEEFwcE1hcENhbGxlckhvc3RIQgAAAAtFAAAAAgAPd2wtZmxvci1hcHZtMTA2SEIAAAAMRQAAAAIAE0FwcE1hcENhbGxlclByb2Nlc3NIQgAAAA1FAAAAAgAGVG9tY2F0SEIAAAAORQAAAAIAClR4blRyYWNlSWRIQgAAAA9FAAAAAgAjNUEyRDkxRjE5OTA2NDExQTAwMTU2RjlCRTAyOEIwNUM5ODU=" />
<To soap:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://fldcvpswa0806.something.com/RTPTransaction/SubmitTransaction.svc?wsdl</To>
<Action soap:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ISubmitTransaction/Submit</Action>
</soap:Header>
<soap:Body>
<ns2:Submit xmlns="http://schemas.datacontract.org/2004/07/RTPTransaction" xmlns:ns2="http://tempuri.org/" xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/">
<ns2:XMLData>
<Creation>2016-03-09 02:10:00</Creation>
<EndOfDays />
<Transactions>
<Transaction>
<BusinessDate>2016-03-09</BusinessDate>
<Items>
<Item>
<Extended>35.0</Extended>
<Number>480000015523</Number>
<Quantity>1</Quantity>
<Taxes>
<Tax>
<Amount>0.00</Amount>
<Rate>0.000</Rate>
<State>FL</State>
<Type>N</Type>
</Tax>
</Taxes>
<Unit>35.0</Unit>
</Item>
</Items>
<Stamp>2016-03-09 00:00:00</Stamp>
<Store>01006</Store>
</Transaction>
</Transactions>
</ns2:XMLData>
</ns2:Submit>
</soap:Body>
</soap:Envelope>

Related

How do I get the WSDL from this .asmx URL?

There's this web service I want to connect to. It's fully detailed here: https://simphonytsapi.docs.apiary.io/#reference/calculatetransactiontotals/overview/example-1?console=1
As you can see there's details on the right on how to connect to it. For example to call the CalculateTransactionTotals method of the web service there is:
This .asmx URL: https://private-102dc-simphonytsapi.apiary-mock.com/1/EGateway/SimphonyPosApiWeb.asmx
And these headers:
Content-Type text/xml;charset=UTF-8
SOAPAction http://micros-hosting.com/EGateway/CalculateTransactionTotals
And this example request body:
<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>
<CalculateTransactionTotals xmlns="http://micros-hosting.com/EGateway/">
<vendorCode />
<ppMenuItems />
<ppComboMeals>
<SimphonyPosApi_ComboMeal>
<ComboMealMainItem>
<Condiments />
<MenuItem>
<ItemDiscount>
<DiscObjectNum>0</DiscObjectNum>
</ItemDiscount>
<MiObjectNum>181020001</MiObjectNum>
<MiReference />
<MiWeight />
<MiMenuLevel>1</MiMenuLevel>
<MiSubLevel>1</MiSubLevel>
<MiPriveLevel>0</MiPriveLevel>
</MenuItem>
</ComboMealMainItem>
<ComboMealMenuItem>
<Condiments />
<MenuItem>
<ItemDiscount>
<DiscObjectNum>0</DiscObjectNum>
</ItemDiscount>
<MiObjectNum>181010001</MiObjectNum>
<MiReference />
<MiWeight />
<MiMenuLevel>1</MiMenuLevel>
<MiSubLevel>1</MiSubLevel>
<MiPriveLevel>0</MiPriveLevel>
</MenuItem>
</ComboMealMenuItem>
<ComboMealObjectNum>11</ComboMealObjectNum>
<SideItems>
<SimphonyPosApi_MenuItem>
<Condiments />
<MenuItem>
<ItemDiscount>
<DiscObjectNum>0</DiscObjectNum>
</ItemDiscount>
<MiObjectNum>181030001</MiObjectNum>
<MiReference />
<MiWeight />
<MiMenuLevel>1</MiMenuLevel>
<MiSubLevel>1</MiSubLevel>
<MiPriveLevel>0</MiPriveLevel>
</MenuItem>
</SimphonyPosApi_MenuItem>
<SimphonyPosApi_MenuItem>
<Condiments />
<MenuItem>
<ItemDiscount>
<DiscObjectNum>0</DiscObjectNum>
</ItemDiscount>
<MiObjectNum>299030001</MiObjectNum>
<MiReference />
<MiWeight />
<MiMenuLevel>1</MiMenuLevel>
<MiSubLevel>1</MiSubLevel>
<MiPriveLevel>0</MiPriveLevel>
</MenuItem>
</SimphonyPosApi_MenuItem>
</SideItems>
</SimphonyPosApi_ComboMeal>
</ppComboMeals>
<pSvcCharge>
<SvcChgObjectNum>0</SvcChgObjectNum>
</pSvcCharge>
<pSubtotalDiscount>
<DiscObjectNum>0</DiscObjectNum>
</pSubtotalDiscount>
<revenueCenter>11</revenueCenter>
<orderType>1</orderType>
<employeeNumber>900000092</employeeNumber>
<pTotalsResponse />
</CalculateTransactionTotals>
</soap:Body>
</soap:Envelope>
I need the WSDL to connect to this web service. How do I get it?

QPlace a pnr to multiple Sabre queues in one step

I would like to QPlace a named pnr onto multiple queues.
The documentation for QueuePlaceLLSRQ_v2.0.4 seems to indicate that this is possible by repeating QueueIdentifier element but I always get errors
<QueueInfo>
<!--Mandatory-->
<!--Repeat Factor=0-3-->
...
<QueueIdentifier PseudoCityCode="IPCC1" PrefatoryInstructionCode="11" Number="400" Name="ABC123"/>
REQUEST AND RESPONSE 1:
<QueuePlaceRQ xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0.4">
<QueueInfo>
<QueueIdentifier PseudoCityCode="7Q9I" PrefatoryInstructionCode="11" Number="204" />
<QueueIdentifier PseudoCityCode="7Q9I" PrefatoryInstructionCode="11" Number="205" />
<UniqueID ID="CIATDK" />
</QueueInfo>
</QueuePlaceRQ>
<stl:ApplicationResults status="NotProcessed">
<stl:Error type="BusinessLogic" timeStamp="2020-02-06T05:02:09-06:00">
<stl:SystemSpecificResults>
<stl:Message>INVALID FORMAT</stl:Message>
<stl:ShortText>ERR.SWS.HOST.ERROR_IN_RESPONSE</stl:ShortText>
</stl:SystemSpecificResults>
</stl:Error>
</stl:ApplicationResults>
REQUEST AND RESPONSE 2:
<QueuePlaceRQ xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0.4">
<QueueInfo>
<QueueIdentifier PseudoCityCode="7Q9I" PrefatoryInstructionCode="11" Number="204" />
<UniqueID ID="ESVDGN" />
<QueueIdentifier PseudoCityCode="7Q9I" PrefatoryInstructionCode="11" Number="205" />
<UniqueID ID="ESVDGN" />
</QueueInfo>
</QueuePlaceRQ>
<stl:SystemSpecificResults>
<stl:Message>cvc-complex-type.2.4.a: Invalid content was found starting with element 'QueueIdentifier'. One of '{"http://webservices.sabre.com/sabreXML/2011/10":UniqueID}' is expected.</stl:Message>
<stl:ShortText>ERR.SWS.CLIENT.VALIDATION_FAILED</stl:ShortText>
</stl:SystemSpecificResults>
REQUEST & RESPONSE 3 (seems to be on-queue only, cannot use named pnr):
<QueuePlaceRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://webservices.sabre.com/sabreXML/2011/10" Version="2.0.4">
<MultiQueuePlace>
<QueueIdentifier PseudoCityCode="7Q9I" PrefatoryInstructionCode="35" Number="205" />
<QueueIdentifier PseudoCityCode="7Q9I" PrefatoryInstructionCode="35" Number="206" />
</MultiQueuePlace>
</QueuePlaceRQ>
<stl:Error type="BusinessLogic" timeStamp="2020-02-06T05:09:53-06:00">
<stl:SystemSpecificResults>
<stl:Message>NO PNR IN AAA</stl:Message>
<stl:ShortText>ERR.SWS.HOST.ERROR_IN_RESPONSE</stl:ShortText>
</stl:SystemSpecificResults>
</stl:Error>
</stl:ApplicationResults>
The correct method is in the question as "REQUEST & RESPONSE 3", but you must have a pnr in your workarea. If you also wish the pnr to remain on the current queue, you should add the current queue as a destination.
<QueuePlaceRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://webservices.sabre.com/sabreXML/2011/10" Version="2.0.4">
<MultiQueuePlace>
<QueueIdentifier PseudoCityCode="7Q9I" PrefatoryInstructionCode="35" Number="205" />
<QueueIdentifier PseudoCityCode="7Q9I" PrefatoryInstructionCode="35" Number="206" />
</MultiQueuePlace>
</QueuePlaceRQ>

The 'Traversal' attribute is not declared. In GetItem EWS request

I have EWS soap request:
<?xml version="1.0" encoding="utf-8"?>
<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/"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrincipalName>room1#exch2010.local</t:PrincipalName>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:GetItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject"></t:FieldURI>
<t:FieldURI FieldURI="calendar:Start"></t:FieldURI>
<t:FieldURI FieldURI="calendar:End"></t:FieldURI>
<t:FieldURI FieldURI="calendar:Location"></t:FieldURI>
<t:FieldURI FieldURI="calendar:Organizer"></t:FieldURI>
<t:FieldURI FieldURI="item:Body"></t:FieldURI>
<t:FieldURI FieldURI="item:TextBody"></t:FieldURI>
</t:AdditionalProperties>
</m:ItemShape>
<m:ItemIds>
<t:ItemId Id="AAAUAHJvb20xQGV4Y2gyMDEwLmxvY2FsAEYAAAAAALp73pDts6BGkBAHp2xunxIHAOLiLPCbqYNEl0bu9R23VJMAAAAW2OQAAOLiLPCbqYNEl0bu9R23VJMAAAAXKY8AAA==" ChangeKey="DwAAAA=="></t:ItemId>
</m:ItemIds>
</m:GetItem>
</soap:Body>
</soap:Envelope>
Response error is:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorSchemaValidation</faultcode>
<faultstring xml:lang="en-US">The request failed schema validation: The 'Traversal' attribute is not declared.</faultstring>
<detail>
<e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorSchemaValidation</e:ResponseCode>
<e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The request failed schema validation.</e:Message>
<t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<t:LineNumber>16</t:LineNumber>
<t:LinePosition>20</t:LinePosition>
<t:Violation>The 'Traversal' attribute is not declared.</t:Violation>
</t:MessageXml>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
Why would it fail?
Similar request
<?xml version="1.0" encoding="utf-8"?>
<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/"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrincipalName>room1#exch2010.local</t:PrincipalName>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:FindItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject"></t:FieldURI>
<t:FieldURI FieldURI="calendar:Start"></t:FieldURI>
<t:FieldURI FieldURI="calendar:End"></t:FieldURI>
<t:FieldURI FieldURI="calendar:Location"></t:FieldURI>
</t:AdditionalProperties>
</m:ItemShape>
<m:CalendarView StartDate="2016-05-30T11:08:48" EndDate="2016-12-31T11:08:48"></m:CalendarView>
<m:ParentFolderIds>
<t:FolderId Id="AAAUAHJvb20xQGV4Y2gyMDEwLmxvY2FsAC4AAAAAALp73pDts6BGkBAHp2xunxIBAOLiLPCbqYNEl0bu9R23VJMAAAAW2OQAAA==" ChangeKey="AgAAABYAAADi4izwm6mDRJdG7vUdt1STAAAAFtkD"></t:FolderId>
</m:ParentFolderIds>
</m:FindItem>
</soap:Body>
</soap:Envelope>
works perfectly
EDIT 1:
I have removed traversal attribute and than got error:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode
xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorSchemaValidation
</faultcode>
<faultstring xml:lang="en-US">The request failed schema validation: The 'FieldURI' attribute is invalid - The value 'item:TextBody' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:UnindexedFieldURIType' - The Enumeration constraint failed.</faultstring>
<detail>
<e:ResponseCode
xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorSchemaValidation
</e:ResponseCode>
<e:Message
xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The request failed schema validation.
</e:Message>
<t:MessageXml
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<t:LineNumber>3</t:LineNumber>
<t:LinePosition>649</t:LinePosition>
<t:Violation>The 'FieldURI' attribute is invalid - The value 'item:TextBody' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:UnindexedFieldURIType' - The Enumeration constraint failed.</t:Violation>
</t:MessageXml>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
Then I removed last Additional property
<t:FieldURI FieldURI="item:TextBody"></t:FieldURI>
and finally got this error.
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="123" MinorBuildNumber="3" Version="Exchange2010_SP2"
xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
</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 EWS Id is in EwsLegacyId format which is not supported by the Exchange version specified by your request. Please use the ConvertId method to convert from EwsLegacyId to EwsId format.</m:MessageText>
<m:ResponseCode>ErrorInvalidIdMalformedEwsLegacyIdFormat</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Items/>
</m:GetItemResponseMessage>
</m:ResponseMessages>
</m:GetItemResponse>
</s:Body>
</s:Envelope>
Please advise.
There is no traversal attribute in the GetItem element you can check the reference documentation https://msdn.microsoft.com/en-us/library/aa563775(v=exchg.150).aspx
Traversals are only valid in FindItem and FindFolder operations (its specifies what scope of Folders you are searching). GetItem is just getting a particular Item you have the Id for (The Id contains the information to locate the Item so any folder/mailbox context isn't needed). That said if you don't have rights to the particular Item and you try to use GetItem the error reported will be that the Item doesn't exist in the store (which is a little deceiving).
Edit 1
You need to start versioning all the EWS Requests you make eg in the Header
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2" />
</soap:Header>
You need to put the schema version https://msdn.microsoft.com/en-us/library/office/dn741586(v=exchg.150).aspx you working with (or at least put Exchange2007_SP1) . That will address the EWSId error (you won't be able to use the Id your trying to use but you should get the correct ID from the other request you got that from).

Link XSD-File in WADL

I would like to create a WADL-File from which Java Interfaces can be created using Apache CXF wadl2java Maven plugin.
In the WADL I would like to use the Datatypes defined in a XSD-File.
These are my REST Services:
#Path("/v1/order")
public interface OrderResource {
#PUT
#Consumes(MediaType.APPLICATION_XML)
public Response createOrder(Order order);
#GET
#Produces(MediaType.APPLICATION_XML)
public List<Order> getOrders(#QueryParam("orderId") List<Long> orderIds);
}
My WADL:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<application xmlns="http://wadl.dev.java.net/2009/02" >
<grammars>
<include href="RestService_schema1.xsd" />
</grammars>
<resources base="http://localhost:9080/rest/">
<resource path="v1/order/" id="OrderResource">
<resource>
<method name="PUT" id="createOrder">
<request>
<representation mediaType="application/xml" />
</request>
<response status="200">
</response>
</method>
</resource>
</resource>
<resource>
<method name="GET" id="getOrders">
<request>
<param name="orderId" style="query" type="xs:long" />
</request>
<response status="200">
<representation mediaType="application/xml" />
</response>
</method>
</resource>
</resources>
</application>
My RestService_schema1.xsd:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Order" type="Order" />
<xs:complexType name="Order">
<xs:attribute name="OrderId" type="orderid">
<xs:annotation>
<xs:documentation>...
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:sequence>
.
.
.
.
</xs:sequence>
</xs:complexType>
<xs:simpleType name="orderid">
<xs:annotation>
<xs:documentation> ....
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:long" />
</xs:simpleType>
</xs:schema>
What I want to do:
I would like to specify in my WADL the input type Order for the createOrder Service. I know this can be done with the element-attribute, but how can I link it? Maybe element="Order" within the <representation>-Tag??
The Query Param of the getOrders()-Service should be List<Long> (in the WADL a List with orderid's) and the Response Type List<Order>. How can I specify this in the WADL?

EWS SOAP get ChangeKey from ID?

using SOAP is it possible to get the ChangeKey of an item identified by Item ID ?
cheers
GetItem might be what you're looking for. The response will include ChangeKey.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2007_SP1" />
<t:TimeZoneContext>
<t:TimeZoneDefinition Id="GMT Standard Time" />
</t:TimeZoneContext>
</soap:Header>
<soap:Body>
<m:GetItem>
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
</m:ItemShape>
<m:ItemIds>
<t:ItemId Id="AAMkADY..." />
</m:ItemIds>
</m:GetItem>
</soap:Body>
</soap:Envelope>