How to pass Schema in Postman for XML Responses? - json

I have received Successful response for a SOAP Post Request in Postman which is well explained in this link. But I want to know how can I pass the Schema for XML responses by the Snippet: Use tiny validator for json data which is used often to validate JSON Schema.
Endpoint:
https://www.w3schools.com/xml/tempconvert.asmx
Body:
<?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/">
<soap:Body>
<FahrenheitToCelsius xmlns="https://www.w3schools.com/xml/">
<Fahrenheit>100</Fahrenheit>
</FahrenheitToCelsius>
</soap:Body>
</soap:Envelope>
Response:
<?xml version="1.0" encoding="utf-8"?>
<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>
<FahrenheitToCelsiusResponse xmlns="https://www.w3schools.com/xml/">
<FahrenheitToCelsiusResult>37.7777777777778</FahrenheitToCelsiusResult>
</FahrenheitToCelsiusResponse>
</soap:Body>
</soap:Envelope>

Related

Fail to operate SyncFolderHierarchy to archivemsgfolderroot

Approximately after 2/22 one of my archive mailbox SyncFolderHierarchy started to encounter this error, but remains work fine.
Is is possible to indicate server failure or some critical server update?
Thanks for help, request, response and headers are enclosed.
https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/syncfolderhierarchy-operation
Request:
<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:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013"/>
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrincipalName>xxx#domain.com</t:PrincipalName>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:SyncFolderHierarchy xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:FolderShape>
<t:BaseShape>IdOnly</t:BaseShape>
</m:FolderShape>
<m:SyncFolderId>
<t:FolderId Id="AAMkAGI2YWI3NDQyLTYyODYtNGY0Zi04YjdiLTdkODhhYzIyZGI1ZAAuAAAAAADhRroG0XH/RKMERX2rvkf2AQBbW0SX+peLTr6oeV2++/0xAAAAAAEJAAA="/>
</m:SyncFolderId>
<m:SyncState></m:SyncState>
</m:SyncFolderHierarchy>
</soap:Body>
</soap:Envelope>
Response & header:
<?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="3912" MinorBuildNumber="25" 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:SyncFolderHierarchyResponse 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:SyncFolderHierarchyResponseMessage ResponseClass="Error">
<m:MessageText>The mailbox operation failed.</m:MessageText>
<m:ResponseCode>ErrorInternalServerError</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:SyncState/>
<m:IncludesLastFolderInRange>true</m:IncludesLastFolderInRange>
</m:SyncFolderHierarchyResponseMessage>
</m:ResponseMessages>
</m:SyncFolderHierarchyResponse>
</s:Body>
</s:Envelope>
cache-control →private
content-encoding →gzip
content-type →text/xml; charset=utf-8
date →Fri, 05 Mar 2021 09:51:41 GMT
request-id →fd1fd1c5-5d03-456c-b947-e1005093f8df
server →Microsoft-IIS/10.0
transfer-encoding →chunked
vary →Accept-Encoding
x-aspnet-version →4.0.30319
x-backendhttpstatus →200, 200
x-beserver →CH2PR13MB3896
x-besku →WCS6
x-calculatedbetarget →CH2PR13MB3896.namprd13.prod.outlook.com
x-calculatedfetarget →CH0PR03CU010.internal.outlook.com
x-diaginfo →CH2PR13MB3896
x-ewshandler →SyncFolderHierarchy
x-feproxyinfo →CH0PR03CA0289.NAMPRD03.PROD.OUTLOOK.COM
x-feserver →CH0PR03CA0289, HK2PR04CA0044
x-ms-appid →28c81f84-52e5-48eb-bd8d-e6e10ba7838c
x-powered-by →ASP.NET
x-proxy-backendserverstatus →200
x-proxy-routingcorrectness →1
x-rum-validated →1

Unable to set CSV as payload in Mule

I am trying to create a flow in Mule 3.7.3 which reads a CSV file from an input folder, does some processing and then writes the original CSV file to an output folder at the end of the flow when everything has completed successfully.
I thought I would save the CSV in a variable and then set the payload using this variable before it creates the file in the output directory.
Everything worked ok when I just had the two sftp connectors to read and write in the flow but then when I added a transform message connector, the file written to the output folder is empty or it fails with a "stream closed" error message. I would have expected the set payload connector to overwrite the transform message so wouldn't have thought there would be a problem.
Does anyone know how I can fix this?
The SFTP server I am using is CrushFTP.
XML flow:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
<http:request-config name="HTTP_Request_Configuration" host="${host}" port="${orderprocess.port}" doc:name="HTTP Request Configuration"></http:request-config>
<sftp:connector name="SFTP" validateConnections="true" doc:name="SFTP" pollingFrequency="1000000"/>
<flow name="userFlow">
<sftp:inbound-endpoint connector-ref="SFTP" host="localhost" port="2222" path="//input" user="${ftp.user}" password="${ftp.password}" responseTimeout="10000" doc:name="SFTP"/>
<set-variable variableName="storeCsv" value="#[payload]" mimeType="application/csv" doc:name="Store CSV"/>
<dw:transform-message doc:name="Transform Message">
<dw:input-payload mimeType="application/csv"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload]]></dw:set-payload>
</dw:transform-message>
<set-payload value="#[flowVars.storeCsv]" mimeType="application/csv" doc:name="Set Payload"/>
<sftp:outbound-endpoint exchange-pattern="one-way" host="localhost" port="2222" responseTimeout="10000" doc:name="SFTP" connector-ref="SFTP" password="${ftp.password}" path="//output" user="${ftp.user}" outputPattern="#[message.inboundProperties.originalFilename+'.processed']"/>
</flow>
</mule>
CSV file
1, user1
Do <object-to-string-transformer/> after <sftp> connector

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>

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>

Mule - Track Order (Tshirt Service) returning Malformed JSON?

I am sending a request to the Mulesoft tshirt service to track the order.
I am sending a JSON request via Postman (Chrome) and I am getting a error returned in Postman: Malformed JSON.
But there is nothing in the Mulesoft Studio console.
Mulesoft Flow
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" version="EE-3.5.0" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd">
<ws:consumer-config doc:name="Web Service Consumer" name="Web_Service_Consumer" port="TshirtServicePort" service="TshirtService" serviceAddress="http://tshirt-service.cloudhub.io" wsdlLocation="tshirt.wsdl"/>
<data-mapper:config doc:name="xml_listinventoryresponse__to_json" name="xml_listinventoryresponse__to_json" transformationGraphPath="xml_listinventoryresponse__to_json.grf"/>
<data-mapper:config doc:name="xml_ordertshirtresponse__to_json" name="xml_ordertshirtresponse__to_json" transformationGraphPath="xml_ordertshirtresponse__to_json.grf"/>
<data-mapper:config doc:name="string_to_xml_authenticationheader_" name="string_to_xml_authenticationheader_" transformationGraphPath="string_to_xml_authenticationheader_.grf"/>
<data-mapper:config name="JSON_To_Xml_OrderTshirt_" transformationGraphPath="json_to_xml_ordertshirt_.grf" doc:name="JSON_To_Xml_OrderTshirt_"/>
<data-mapper:config name="JSON_To_Xml_TrackOrder_" transformationGraphPath="json_to_xml_trackorder_.grf" doc:name="JSON_To_Xml_TrackOrder_"/>
<data-mapper:config name="XML_To_JSON" transformationGraphPath="xml_to_json.grf" doc:name="XML_To_JSON"/>
<flow name="OrderTracking" doc:name="OrderTracking">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8001" path="orderTracking" doc:name="HTTP"/>
<data-mapper:transform config-ref="JSON_To_Xml_TrackOrder_" doc:name="JSON To Xml<TrackOrder>"/>
<ws:consumer config-ref="Web_Service_Consumer" operation="TrackOrder" doc:name="TrackOrder"/>
<data-mapper:transform config-ref="XML_To_JSON" doc:name="XML To JSON"/>
<http:response-builder status="200" contentType="application/json" doc:name="HTTP Response Builder"/>
</flow>
</mule>
JSON request
{
"email":"info8001#mulesoft.com",
"orderId":"264"
}
It appears your JSON request it not proper.
The JSON you provided when converted to XML will be as follows
<?xml version="1.0" encoding="UTF-8" ?>
<email>info8001#mulesoft.com</email>
<orderId>264</orderId>
Which is not complete as there is no root element to enclose the data in the XML.
Try modifying your JSON and see if it works.