WSDL soap response validation - wsdl

I have a wsdl that defines a schema with:
<xsd:schema elementFormDefault="unqualified"
targetNamespace="http://www.xpto.com/xpto">
and the element:
<xsd:element name="insertResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="sys_id"
type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="table"
type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="display_name"
type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="display_value"
type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="status"
type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="status_message"
type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="error_message"
type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
but when i execute the operation and get the response, SoapUI says its invalid:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<insertResponse xmlns="http://www.xpto.com/xpto">
<sys_id>something</sys_id>
<table>something</table>
<display_name>number</display_name>
<display_value>something</display_value>
<status>something</status>
</insertResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The SoapUI message (with lines wrapped for legibility):
line 4: Expected element 'sys_id' instead of
'sys_id#http://www.xpto.com/xpto' here in element
insertResponse#http://www.xpto.com/xpto
If i change the WSDL to include elementFormDefault="qualified", in the schema, the same response is valid.
Why is this response invalid without elementFormDefault="qualified" and what is the correct way to do it?
Also the code generated against this WSDL doesn't like the response either, failing with:
Unmarshalling Error: unexpected element
(uri:\\"http://www.xpto.com/xpto\\", local:\\"sys_id\\"). Expected
elements are <{}table>,<{}display_value>,<{}display_name>,
<{}error_message>,<{}sys_id>,<{}status_message>,<{}status>
(Again, lines wrapped for legibility.)
Using apache-cxf.

Before your question can be answered clearly, some background information appears to be needed.
In XSD, elements declared within a complex type definition are said to be local to that type. (The alternative is to declare them independently, as top-level elements; then they are global or top-level. Not coincidentally, the top-level elements are those whose declarations are at the top level of the schema document, i.e. those which are children of xsd:schema.)
Every element declared in an XSD schema has a name consisting of a namespace name and a local name. As with XML names generally, the namespace name may be null. When the element's name has a non-null namespace name, it is said to be namespace-qualified; when the namespace name is null, by contrast, the element's name is unqualified.
Top-level element declarations take their namespace from the targetNamespace attribute on the enclosing xsd:schema element. Local element declarations, on the other hand, pose a design question: do they go into the target namespace (i.e. should their names be namespace-qualified)? Or should they have unqualified names?
There are two schools of thought on this in the XSD user community, and there were two schools of thought in the responsible WG. Some feel that any element declared in a schema document for namespace foo should be in namespace foo -- after all, one of the functions of a namespace is to tell you where the element comes from, which is a first step toward finding documentation. Others feel that local elements depend on their containing type in just the same way that attributes do -- and local attributes have unqualified names. The one thing both sides agree on is that the other guys are crazy and that no one with two brain cells to rub together could ever actually believe that things should be that way.
The form attribute on local element declarations is used to control whether the local element in question has a qualified name or an unqualified name; unsurprisingly, the two values it can take are qualified and unqualified. The elementFormDefault attribute on the xsd:schema element is used to specify which of those values should be the default value in the current schema document; its value defaults to unqualified, but it is almost always good practice to specify it explicitly, since otherwise some readers will be confused.
With that background information, it's now possible to answer your question: Why is this response invalid without elementFormDefault="qualified" and what is the correct way to do it?
The insertResponse element declared in the schema, being top-level, has the expanded name (http://www.xpto.com/xpto, insertResponse) -- sometimes expanded names are written in the form {http://www.xpto.com/xpto}insertResponse, and apparently sometimes (as illustrated by your error message) in the form insertResponse#http://www.xpto.com/xpto.
When the schema document does not specify elementFormDefault = "qualified", the form of local element names defaults to unqualified. That means the expanded names of the 'sys_id', 'table', 'display_name', and the other local elements all have a null namespace part, so their expanded names are {}sys_id, {}table, {}display_name, etc. But the document you show has the form
<insertResponse xmlns="http://www.xpto.com/xpto">
<sys_id>something</sys_id>
<table>something</table>
<display_name>number</display_name>
...
The default namespace declaration on insertResponse ensures that the name given as 'sys_id' in the first child element is expanded to {http://www.xpto.com/xpto}sys_id, and similarly for the other children. The basic rule of matching for expanded names in pretty much all XML technologies is that an explicit namespace name like {http://www.xpto.com/xpto} does not match the null namespace name {}. So the element name {http://www.xpto.com/xpto}sys_id does not match the element declaration for an element named {}sys_id. An element required by the schema is not found in the instance, and an element is found in the instance which matches nothing in the declaration. So the insertResponse element is invalid.
When the schema document specified elementFormDefault="qualified", the local elements sys_id etc. are namespace qualified. So the expanded name found in the instance document and the expanded name associated with the declaration in the schema are both the same, namely {http://www.xpto.com/xpto}sys_id. All is well, the document is valid, and life is good, or at least as good as it gets when you are working with SOAP.
Bottom line: the creator of the response message and the creator of the schema are not currently in agreement on what the response is supposed to look like. The correct way to do it is for both of them to understand how namespace qualification works in XML and in XSD, and to agree on what form the response should take.
Good luck.

Related

SoapUI seems to be incorrectly saying these restrictions are invalid. What am I doing wrong?

I have the following in my XML Schema:
<xsd:simpleType name="DECIMAL_TYPE">
<xsd:restriction base="xsd:double">
<xsd:minInclusive value="-100000"/>
<xsd:maxInclusive value="100000"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ANGLE_VALUE_TYPE">
<xsd:restriction base="DECIMAL_TYPE">
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="360"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="ANGLE_TYPE">
<xsd:simpleContent>
<xsd:extension base="ANGLE_VALUE_TYPE">
<xsd:attribute name="UNITS" type="xsd:string" fixed="degrees"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="SPECIAL_ANGLE_TYPE">
<xsd:simpleContent>
<xsd:restriction base="ANGLE_TYPE">
<xsd:maxInclusive value="90" /> <!-- The source of the problem -->
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
This schema is used in a WSDL that I'm using as the basis for a new SoapUI project. However, when I try to import the project, SoapUI gives this error:
There was something wrong with the WSDL you are trying to import:
Source: null
Error: Must be less than or equal to previous maxInclusive
If I change the '90' in the problem line to be equal to '360', the same error appears.
If I remove the line with the comment ("The source of the problem") then SoapUI imports the WSDL just fine. The schema successfully validates in Eclipse, and WSDL2Java runs fine on it.
What, if anything, is wrong with my schema, and what do I need to do to import this to SoapUI? Thank you!
I wonder if your problem is related to the fact that ANGLE_TYPE names ANGLE_BASE_TYPE as its base type, but your schema fragment has no declaration for such a type.
When I change the declaration to name ANGLE_VALUE_TYPE, both Saxon and Xerces tell me the schema document is valid, and once augmented with some element declarations it seems to behave as desired.

Fetching attribute value from property using ant - may be with propertyregex

I tried using linecontainsregexp within filterchain ant-task by framing regexp pattern holding unique server name say 'act1' & now property holds value like this:
<Server name="act1" value="ServerName" port="1234"></Server>
How to get individual attribute names?. For eg if I want to get port #, how to retrieve it. I tried with something like:
<propertyregex property="extracted.prop" input="${server.details}"
regexp="(.*)\\ *##" select="\1" />
thank you.
The code below should work to extract each of the three attributes. First, notice that I'm loading the entire xml file. It isn't necessary to extract the specific line as you were doing. Secondly, I wrote it to be flexible enough to allow line breaks in the Server properties and to allow any order of the attributes.
I see that you were really struggling with the regex in particular. For your understanding, I'll break down the first regex:
(?s) // DOTALL flag. Causes the . wildcard to match newlines.
\x3c // The < character. For reasons I don't understand, `propertyregex` doesn't allow <
Server // Match 'Server' literally
.*? // Reluctantly consume characters until...
name= // 'name=' is reached
" // Because ant is an XML file, we must use this escape sequence for "
(.*?) // Reluctantly grab all characters in a capturing group until...
" // another double quote is reached.
And finally the XML:
<loadfile property="server.details" srcfile="${baseDir}/build/myTest.xml"/>
<propertyregex property="server.name"
input="${server.details}"
regexp="(?s)\x3cServer.*?name="(.*?)""
select="\1" />
<propertyregex property="server.value"
input="${server.details}"
regexp="(?s)\x3cServer.*?value="(.*?)""
select="\1" />
<propertyregex property="server.port"
input="${server.details}"
regexp="(?s)\x3cServer.*?port="(.*?)""
select="\1" />

How to extend BPMN 2.0

Currently, I'm investigating the ways to extend BPMN. I want to create a new task type with less properties than a task and also with some non-BPMN properties and a new type of pool.
Until now I saw that people mentioned of two ways, using Extension Points and using an external schema. Unfortunately in Internet, I could not find that many resources to understand these methods extensively.
What I understood from these methods:
Extension Points: There are some standard extension points provided by BPMN engine vendors (Aktiviti, jBPM, etc...). For instance in Activiti there is a Custom Service Task which can be extended with user desired properties but I did not find any resources if this newly created extension task can be deployed on the Aktiviti workflow engine and also it would be nice to see the new BPMN schema for this extension.
Using an external schema: Defining desired properties in an external schema and referencing this schema from Semantic.xsd. In this case we will also need to adapt our Workflow Engine but it's more flexible than the method I mentioned before or am I missing missing something?
The only thing that is not clear is this method does not extend directly task definition so these properties can be used by every element in BPMN?
An example external schema is:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="http://myproject.org//bpmn/extensions/NEWTask"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:exvar="http://myproject.org/externalDefs"
targetNamespace="http://myproject.org//bpmn/extensions/NEWTask"
>
<xsd:import namespace="http://www.omg.org/spec/BPMN/20100524/MODEL" schemaLocation="BPMN20.xsd"/>
<xsd:import schemaLocation="externalDefs.xsd" namespace="http://myproject.org/externalDefs" />
<xsd:complexType name="tProperty1" abstract="false">
<xsd:sequence>
<xsd:any namespace="##any" processContents="lax" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
<xsd:group id="tNEWTask" name="tNEWTask">
<xsd:sequence>
<xsd:element name="Property2" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="Property1" type="tProperty1" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="Property2" type="exvar:Varaible1" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:group>
</xsd:schema>
Are there any other methods for extending BPMN or any resources that you can point me so that I can have a better insight about this topic?
Any help will be appreciated, thanks in advance!
There's this tool developed by a brazilian researcher: http://code.google.com/p/bpmnx/
it works on extension points as far as i remember.
As you are not talking about any concrete BPMN implementation (activiti, jbpm), and you are talking about your own process engine I assume that what you want to do is extend the XML in accordance to BPMN rules.
That said, you can look at BPMN 2.0 specification (I think it's very long, and probably boring) or you can try to look at some bpmn book. BPMN method & style book has a part about implementing BPMN, so maybe that's useful to you.
Note: When there's a standard like BPMN, which has a lot of support, sometimes it's useful if you really need to extended. Is it worth extending something standard, which hasn't been considered? (Not saying you can't do it, but you should think what it brings to you and if couldn't you do it with the regular stuff).
Here is some discussion of this topic on the Activiti Forums and on the MDT Eclipse plugin forum.
Unfortunately, with some simple testing I have not been able to implement a new namespace
(e.g. xmlns:newns="http://www.mynewns.com/newns in
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
typeLanguage="http://www.w3.org/2001/XMLSchema"
xmlns:newns="http://www.mynewns.com/newns"
expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="http://www.activiti.org/bpmn2.0">
and an element like <userTask newns:ownerID="owner1">).
Custom elements in my Activiti diagram don't work either -- the Eclipse plugin seems to discard my custom namespace and ignore my elements. Don't know why; still researching.
You can take a look at the Eclipse BPMN2 Modeler.
There are some tutorials available (e.g. extending the runtime and creating a custom task).

parseKml() error

I have noticed that parseKml() function does not parse KML file correctly. For example, if you have this bit of KML:
<ExtendedData>
<Data name="Offer">
<value>Apples</value>
<value>Potatoes</value>
<value>Tomatoes</value>
</Data>
</ExtendedData>
The parseKml() function will return a kmlObject that will contain only the last value, i.e. "Tomatoes":
Does anyone have a solution for this?
The structure for the type of extended data you are using is for name/value pairs. i.e. a single name with a single value.
<ExtendedData>
<Data name="string">
<displayName>...</displayName> <!-- string -->
<value>...</value> <!-- string -->
</Data>
</ExtendedData>
So what you are trying will not work. If you wish to add an arbitrary XML Data structure to a KML Feature then you would do it like this.
<ExtendedData xmlns:offer="http://yourserver.com/namespace">
<offer:item>Apples</offer:item>
<offer:item>Potatoes</offer:item>
<offer:item>Tomatoes</offer:item>
</ExtendedData>
Based on the data structure, the 'offer' XML Schema file (http://yourserver.com/namespace) would be something like.
<?xml version="1.0" encoding="utf-16"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="item" type="xsd:string" />
</xsd:schema>
I believe the <Data> element can only contain a single <value> - according to the docs, the "<Data> element allows you to add untyped name/value pairs to the user data associated with a given Feature."
So in your case, it's picking up the last <value> element only. You might find another way to add your custom data here: https://developers.google.com/kml/documentation/extendeddata

custom binding to force Inner class creation or getters/setters for xs:element

I have a schema declaration as follow from a third-party provider.
<xs:complexType name="GroupParameterType">
<xs:sequence minOccurs="0" maxOccurs="4">
<xs:element name="name" type="xs:string">
<xs:annotation>
<xs:documentation>The name of the parameter.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="value" type="xs:string">
<xs:annotation>
<xs:documentation>The value of the parameter.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
Above is the schema that i CANNOT change. I am trying to write a custom binding for jaxb 2.0 such that I can refer to name as GroupParameterType.Name or GroupParameterType.Value in java code.
Current default binding generates List for me i.e. getNameandValueList, but I want separate getters and setters for name and value respectively.
I tried putting in a custom binding like the following :
<jxb:bindings schemaLocation="GroupParameter.xsd" node="xs:element[#name='name']">
<jxb:globalBindings localScoping="toplevel" generateIsSetMethod="true"/>
</jxb:bindings>
<jxb:bindings schemaLocation="GroupParameter.xsd" node="xs:element[#name='value']">
<jxb:globalBindings localScoping="toplevel" generateIsSetMethod="true"/>
</jxb:bindings>
and it did nothing to change the default class generation. Can anyone give me some pointers as so what else can I try next ? I am looking to have the default List generation ALONG WITH the getters/setters for name and value OR have name and value as Inner Classes. If i remove the maxOccurs=4 option, I can generate getters/setters but since I can't modify the schema, I am trying to get that behavior using external binding file.
Thanks
Shon
You can't get this behaviour unless you modify your schema. You do have a schema model which maps to a heterogeneous element property, and you can't change it with a customization.
You can try the code injection plugin as the last retreat.

Resources