Order of unbounded elements in xmlschema sequence - soap

I'm currently developing an application that uses webservices (SOAP 1.2). I'm interested in knowing if I can rely on the order of unbounded elements in a xmlschema sequence. Here is my definition of that sequence in the wsdl I'm using.
<xsd:complexType name="IdList">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="id" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
Does that give me any kind of guarantee on the order of the elements? Say this is an excerpt of the associated soap message:
<web:globalRecipientIds>
<!--Zero or more repetitions:-->
<web:id>1</web:id>
<web:id>15</web:id>
<web:id>7</web:id>
</web:globalRecipientIds>
Does that mean that the receiving end will treat it in the order that it appears in the SOAP message? Is this something that depends on the implementation of the receiving end? If it does, I generated the receiving end using wsdl2java from apache axis to generate the java code from the wsdl file. Can you tell me something specific about this?

The order of XML elements is significative - regardless of the schema - e.g.
<web:globalRecipientIds>
<web:id>1</web:id>
<web:id>15</web:id>
<web:id>7</web:id>
</web:globalRecipientIds>
and
<web:globalRecipientIds>
<web:id>15</web:id>
<web:id>1</web:id>
<web:id>7</web:id>
</web:globalRecipientIds>
are two different XML, and XML tools (should) preserve and recognize the order of elements.
Having said that, this does not guarantee that 'the receiving end will treat it in the order that it appears in the SOAP message' - depends on what the receiving end does with the XML. It receives an ordered list of ids, but if (for example) puts those ids in a dictionary or some other hashed structure the order is lost.

Related

SOAP request XML elements order (node-soap)

Using node-soap, when making a SOAP call, the XML elements are ordered by the order I write them in the request object (which is not reliable in JavaScript - nor is it maintainable at scale over time).
I've read that in some cases the order of the elements matter and it may require to organize the XML elements in the same order that appear in the WSDL - This appear to be the my case.
Consider this example:
<Request>
<Element2>
<SubElement1>
<SubElement2>
</Element2>
<Element1>
<SubElement3>
<SubElement4>
</Element1>
</Request>
For this WSDL:
<Request>
<Element1>
<SubElement3>
<SubElement4>
</Element1>
<Element2>
<SubElement1>
<SubElement2>
</Element2>
</Request>
For this request I would get an error that <Element1> is missing.
I could not find an option in node-soap to force the elements order by the WSDL.
Am I missing it or is there another way around.

Passing encoded XML content in SOAP envelop request in Java application

I'm developing a Java application where I need to make a web service request using SOAP protocol. In that SOAP envelop request, one of the XML attribute/property called content will hold the XML file itself like below:-
<n1:envelope>
<message>
<id>67872894892424</id>
</message>
<sender agency="GS1" scheme="tGLK">ur.0</sender>
<recipients>
<id agency="GS1" scheme="tGLK">test</id>
</recipients>
<content encoding="XML" extension="A" format="ATTP">
------
----
</content></n1:envelope>
I'm new to it and requires some assistance in clarifying my doubts. I'm using JDK1.8 and Apache CXF. How can I do marshaling/unmarshalling for this particular content attribute? Normal SOAP envelops request is easy to do it but not sure how to pass an encoded XML itself in SOAP request. Is there any reference links? Thanks
Your case is an example of including XML inside XML. Yes, XML could be included inside an SOAP(XML), there are two ways, though both means almost same thing.
Using CDATA encoding
<hello><![CDATA[<El><E2><E3 attr="D1">Text</E3></E2></El>]]></hello>
Converting the XML into text by replacing, < with <, " with &quote; and > with >
<hello><El><E2><E3 attr="D1">Text</E3></E2></El></hello>
To
<hello>>El<>E2<>E3 attr="D1"<Text>/E3<>/E2<>/El<</hello>
Hence, to include the XML inside SOAP, while adding the XML element, you need to follow either approach while marshaling/unmarshaling.

Unable to receive message from WEB-SPHERE MQ queue by using Citrus Frame work xml test cases

I am trying to receive messages from web-sphere mq queue by using citrus framework by defining actions in XML-test-cases. as shown below.
<receive endpoint="jms:Queue_Name?timeout=1000">
<selector>
<element name="correlationId" value="303132333435363738393130313131323133313431353136"
</selecotr>
<message>
</message>
</receive>
I tried mentioning correlation id with hexadecimal value and ASCII value but I am unable to get the message I am getting ACTION TIME OUT EXCEPTION. I cross checked correlation id that existed in WEB-SPHERE MQ with mentioned correlation id in xml. but without selector tag I am able to get the message that was inserted first in the queue based on time.
You have to give correlation ID value like this it will work for you
<receive endpoint="jms:Queue_Name?timeout=1000">
<selector>
<element name="correlationId" value="ID:${varible consisting og hexa value}"
</selecotr>
<message>
</message>
</receive>

SOAP WSDL sequence definition - one argument or many?

Problem/Intro
I have not really used SOAP in very many years due to REST.
I have the following definition in a WSDL file:
<xs:complexType name="findByIdentifier">
<xs:sequence>
<xs:element name="arg0" type="xs:long"/>
</xs:sequence>
</xs:complexType>
The code method generated from WSDL2Java is
findByIdentifier(
#WebParam(name = "arg0", targetNamespace = "")
long arg0
)
The requirements specify that I should submit an array of long.
I see also that maxOccurs and minOccurs are missing from the WSDL.
Question
How should I modify the WSDL file I have in my project in order to have a method generated that takes an array?
If I should not hack the WSDL should I do something else like a custom implementation via an extended class or a custom client implementation (defeats the purpose of generating code)?
The solution as proposed by the team leader was to use a loop since the WSDL and the actual webservice behavior show that an array is not supported for an argument.

At least one WSDL with at least one service definition needs to be provided

I have defined my service on the WSDL file this way:
<wsdl:service name="guestbook">
<wsdl:port binding="tns:guestbookSOAP" name="guestbookSOAP">
<soap:address location="http://localhost:8080/soapguestbook"/>
</wsdl:port>
Still I am getting the following error message when running wsimport on it:
At least one WSDL with at least one service definition needs to be provided.
Is there anything else I need to add?
The problem in your case is that the definitions element is missing, which is like a root.
WSDL has a specific structure, for which the root element should be the DEFINITIONs, under it various other elements are present like types, messages, portType, binding, services etc.
The structure is like the below:
<definitions>
<types> data type definitions........ </types>
<message> definition of the data being communicated.... </message>
<portType> set of operations...... </portType>
<binding> protocol and data format specification.... </binding>
</definitions>
For the meaning of each WSDL element look into the link:
https://www.w3schools.com/xml/xml_wsdl.asp