Soap Envelope HTML Payload issue com.ctc.wstx.exc.WstxParsingException: Unexpected '<' - soap

I'm working on the legacy soap API to modify. I have to add an email body in the payload when I'm sending simple text it works fine when I send "<p>test</p>" or HTML it gives me an error.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>com.ctc.wstx.exc.WstxParsingException: Unexpected '<' in attribute value
at [row,col {unknown-source}]: [32,57]</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
my soap API written in ColdFusion 10
XSD
<xs:element name="parameter" minOccurs="0" maxOccurs="unbounded">
<xs:complexType mixed = "true">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="value" use="required" type="xs:string" />
</xs:complexType>
</xs:element>

You want to use encodeForXML (https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-e-g/encodeforxml.html) to escape the content first. If that's not available in CF10, the older XmlFormat (https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-t-z/xmlformat.html).

Related

How to validate XSD in Swift?

I have i.e. this XML:
<?xml version="1.0" encoding="UTF-8" ?>
<individual>
<name>Baeldung</name>
<address>
<zip>00001</zip>
<city>New York</city>
</address>
</individual>
and would validate, wether it matches this schema:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="individual">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:element name="address">
<xs:complexType>
<xs:sequence>
<xs:element name="zip" type="xs:positiveInteger" />
<xs:element name="city" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Is it any Swift technic to do it?
I looked at Apple XMLDocument library, but it does DTD validation. I think this is something else: https://developer.apple.com/documentation/foundation/xmldocument
Found this online tool, but it is not Swift: https://www.liquid-technologies.com/online-xsd-validator

What is the correct format for SOAP data? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a file, I shared it here http://codepad.org/V6FR2Wbs
It seems this file contains SOAP data. But I do not confirm that this contains SOAP data.
So I want to know, is there any specific format for SOAP data.
I got a similar question here What is the correct format of a SOAP response, but I don't see any format related information there.
There is very simple way to validate if request or response SOAPMessage is valid or not.
As a part of SOAP Message, it includes the namespace that points to SOAP XSD aka. XML schema definition, and the message be valid as per that XSD.
In your example, the SOAP message is--
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cwmp="urn:dslforum-org:cwmp-1-0"> <SOAP-ENV:Header> <cwmp:ID SOAP-ENV:mustUnderstand="1">279384</cwmp:ID> </SOAP-ENV:Header> <SOAP-ENV:Body> <cwmp:Inform> <DeviceId> <Manufacturer>Huawei Technologies Co., Ltd</Manufacturer> <OUI>00259E</OUI> <ProductClass>EG8040H5</ProductClass> <SerialNumber>48575443FF5E5D9D</SerialNumber> </DeviceId> <Event SOAP-ENC:arrayType="cwmp:EventStruct[1]"> <EventStruct> <EventCode>2 PERIODIC</EventCode> <CommandKey/> </EventStruct> </Event> <MaxEnvelopes>1</MaxEnvelopes> <CurrentTime>2019-06-19T15:30:33+00:00</CurrentTime> <RetryCount>0</RetryCount> <ParameterList SOAP-ENC:arrayType="cwmp:ParameterValueStruct[8]"> <ParameterValueStruct> <Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name> <Value xsi:type="xsd:string"/> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name> <Value xsi:type="xsd:string">http://10.240.12.35:7547/1d9564b694ef18090a9377cd6f3217eb</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceSummary</Name> <Value xsi:type="xsd:string">InternetGatewayDevice:1.4[](Baseline:1, EthernetLAN:1, WiFiLAN:2, Time:1, IPPing:1, DeviceAssociation:1)</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.SpecVersion</Name> <Value xsi:type="xsd:string">1.0</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name> <Value xsi:type="xsd:string">172D.A</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name> <Value xsi:type="xsd:string">V5R019C00S115</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name> <Value xsi:type="xsd:string"/> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress</Name> <Value xsi:type="xsd:string">10.240.12.35</Value> </ParameterValueStruct> </ParameterList> </cwmp:Inform> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
In your example SOAP schema is located as http://schemas.xmlsoap.org/soap/envelope/
And the XSD for that schema is--
<?xml version='1.0' encoding='UTF-8' ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"
targetNamespace="http://schemas.xmlsoap.org/soap/envelope/" >
<!-- Envelope, header and body -->
<xs:element name="Envelope" type="tns:Envelope" />
<xs:complexType name="Envelope" >
<xs:sequence>
<xs:element ref="tns:Header" minOccurs="0" />
<xs:element ref="tns:Body" minOccurs="1" />
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
<xs:element name="Header" type="tns:Header" />
<xs:complexType name="Header" >
<xs:sequence>
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
<xs:element name="Body" type="tns:Body" />
<xs:complexType name="Body" >
<xs:sequence>
<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="##any" processContents="lax" >
<xs:annotation>
<xs:documentation>
Prose in the spec does not specify that attributes are allowed on the Body element
</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
</xs:complexType>
<!-- Global Attributes. The following attributes are intended to be usable via qualified attribute names on any complex type referencing them. -->
<xs:attribute name="mustUnderstand" >
<xs:simpleType>
<xs:restriction base='xs:boolean'>
<xs:pattern value='0|1' />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="actor" type="xs:anyURI" />
<xs:simpleType name="encodingStyle" >
<xs:annotation>
<xs:documentation>
'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing element. For example, the value 'http://schemas.xmlsoap.org/soap/encoding/' indicates the pattern described in SOAP specification
</xs:documentation>
</xs:annotation>
<xs:list itemType="xs:anyURI" />
</xs:simpleType>
<xs:attribute name="encodingStyle" type="tns:encodingStyle" />
<xs:attributeGroup name="encodingStyle" >
<xs:attribute ref="tns:encodingStyle" />
</xs:attributeGroup>
<xs:element name="Fault" type="tns:Fault" />
<xs:complexType name="Fault" final="extension" >
<xs:annotation>
<xs:documentation>
Fault reporting structure
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="faultcode" type="xs:QName" />
<xs:element name="faultstring" type="xs:string" />
<xs:element name="faultactor" type="xs:anyURI" minOccurs="0" />
<xs:element name="detail" type="tns:detail" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="detail">
<xs:sequence>
<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
</xs:sequence>
<xs:anyAttribute namespace="##any" processContents="lax" />
</xs:complexType>
</xs:schema>
Using any programming language or API or online service, you could validate the SOAP message against the given XSD manually or automated way.
E.g.
As I did using this online service(https://www.liquid-technologies.com/online-xsd-validator) and your SOAP message found valid against the schema.

SOAP Payload with nested complexType

I'm trying to make a SOAP request where a parameter is a complex type, and I'm having trouble getting the syntax right.
WSDL: https://www.dayforcehcm.com/DataSvc/DayforceService.svc?singleWsdl
Action: IDayforceService/Query
Here is the SOAP request that was generated by SoapUI:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://Dayforce/Services/DayforceService">
<SOAP-ENV:Body>
<ns1:Query>
<ns1:sessionTicket>?</ns1:sessionTicket>
<ns1:request/>
</ns1:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
My question is how to fill in the <ns1:request/> element. The request should be a GetReportDefinitionsRequest, and it needs to provide a string value for XRefCode.
SoapUI isn't being much help here, and WSDL to class generators I've tried have similar problems. At this point I'd settle for just knowing the proper XML syntax
Here are the relevant types (also available in the WSDL above).
Query:
<xs:element name="Query">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="sessionTicket" nillable="true" type="xs:string"/>
<xs:element xmlns:q9="http://Dayforce/Services/Data" minOccurs="0" name="request" nillable="true" type="q9:DFRequest"/>
</xs:sequence>
</xs:complexType>
</xs:element>
GetReportDefinitionsRequest:
<xs:complexType name="GetReportDefinitionsRequest">
<xs:complexContent mixed="false">
<xs:extension base="tns:DFRequest">
<xs:sequence>
<xs:element minOccurs="0" name="XRefCode" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="GetReportDefinitionsRequest" nillable="true" type="tns:GetReportDefinitionsRequest"/>
DFRequest:
<xs:complexType name="DFRequest">
<xs:complexContent mixed="false">
<xs:extension base="tns:DFObject">
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="DFRequest" nillable="true" type="tns:DFRequest"/>
DFObject:
<xs:complexType name="DFObject">
<xs:sequence/>
</xs:complexType>
<xs:element name="DFObject" nillable="true" type="tns:DFObject"/>
I was able to get the sample code running and hook in to get the XML generated for the request. Here's the result, in case it helps anyone in the future.
The important part is to assign the type attribute to the tag. That involves importing the http://www.w3.org/2001/XMLSchema-instance namespace to get the type attribute, and the http://Dayforce/Services/Data namespace for the type itself.
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dfs="http://Dayforce/Services/DayforceService">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<dfs:Query>
<dfs:sessionTicket>?</dfs:sessionTicket>
<dfs:request
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dfd="http://Dayforce/Services/Data"
i:type="dfd:GetReportDefinitionsRequest">
<dfd:XRefCode>?</dfd:XRefCode>
</dfs:request>
</dfs:Query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

XML to CSV with data header using Liquid Data Mapper

I have an XML file that describes a header and a list. I need to generate a CSV file where the first line of the file is constructed from the header information and the subsequent lines of the file constructed from the list. The header has a different number of columns to the list items.
This is easy to do with xsl. How can I do it with the data mapper using the .NET mapping engine?
A simple example to explain. XSD of input xml
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="A" />
<xs:element name="B" />
<xs:element name="Line" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="C" />
<xs:element name="D" />
<xs:element name="E" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
An Example Input XML
<Root>
<A>Header Value</A>
<B>112233</B>
<Line>
<C>22</C>
<D>Fred</D>
<E>1</E>
</Line>
<Line>
<C>34</C>
<D>Jim</D>
<E>2</E>
</Line>
<Line>
<C>42</C>
<D>Amanda</D>
<E>1</E>
</Line>
<Line>
<C>1267</C>
<D>Vickie</D>
<E>2</E>
</Line>
</Root>
Required Text Output:
Header Value|112233
22|Fred|1
34|Jim|2
42|Amanda|1
1267|Vickie|2
Generating either
Header Value|112233
or
22|Fred|1
34|Jim|2
42|Amanda|1
1267|Vickie|2
as individual csv files is easy (as it should be) but how can I can't see how to produce the required file other than resorting back to xslt.
You can set up a transform that looks something like this if you want to be able to dynamically set the headers.
You double up the 'Row' inputs using the 'Duplicate' option
Before you do that you need to tweak your schema. The input values A-E need typing (note the type="xs:string").
<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid Studio 2019 (https://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="A" type="xs:string" />
<xs:element name="B" type="xs:string" />
<xs:element name="Line" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="C" type="xs:string" />
<xs:element name="D" type="xs:string" />
<xs:element name="E" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
This will give you output data that looks like this (note it always outputs 3 columns, so you get a trailing '|').
Header Value|112233|
22|Fred|1
34|Jim|2
42|Amanda|1
1267|Vickie|2
If you just want the data and no header then you can just connect it up like this

IPhone-XPath query wont retrieve my node

I'm using GData as my XML parser.
I've tried using an XPath query to retrieve a node -
#"//GetPlacesAutoCompleteResult".
but getNodesForXPath doesn't return any nodes.
so I'm asking, what's wrong with the query I typed in?
P.S
I'm only looking for a way to find out if the node exists or not, I care not about it's child nodes.
here is my .xml file (a result from a soap query to an .ASMX Web-Service).
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetPlacesAutoCompleteResponse
xmlns="http://xxxxxxx.com/xxxxxx/webservice">
<GetPlacesAutoCompleteResult>
<xs:schema id="NewDataSet"
xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet"
msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0"
maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="ID"
type="xs:long"
minOccurs="0"/>
<xs:element name="FullName"
type="xs:string"
minOccurs="0"/>
<xs:element name="PlaceTypeID"
type="xs:int"
minOccurs="0"/>
</xs:sequence>
</xs:complexType></xs:element>
</xs:choice>
</xs:complexType></xs:element>
</xs:schema>
<diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Table diffgr:id="Table1" msdata:rowOrder="0">
<ID>47393</ID>
<FullName>Yifat</FullName>
<PlaceTypeID>10</PlaceTypeID>
</Table>
<Table diffgr:id="Table2" msdata:rowOrder="1">
<ID>48497</ID>
<FullName>Haifa</FullName>
<PlaceTypeID>10</PlaceTypeID>
</Table>
<Table diffgr:id="Table3" msdata:rowOrder="2">
<ID>70827</ID>
<FullName
>Haifa - Central Bus Rishon</FullName>
<PlaceTypeID>120</PlaceTypeID>
</Table>
</NewDataSet>
</diffgr:diffgram>
</GetPlacesAutoCompleteResult>
</GetPlacesAutoCompleteResponse>
</soap:Body>
</soap:Envelope>
Well with <GetPlacesAutoCompleteResponse xmlns="http://xxxxxxx.com/xxxxxx/webservice"><GetPlacesAutoCompleteResult> you have a default namespace declaration in scope so assuming you use XPath 1.0 you need to bind a prefix to the namespace URI http://xxxxxxx.com/xxxxxx/webservice and use that prefix to qualify element names. For example if the prefix is ws then you would use //ws:GetPlacesAutoCompleteResult.
How you bind a prefix to a namespace URI depends on the XPath API you use, I am not familiar with GData so I can't help you with a code sample.