WSDL not building correctly when extension and elements are used in the same object - soap

Whenever I try to build the wsdl file it won't correctly build the object when its inherited and has a sequence of elements listed. For example...
<xs:complexType name="Triangle">
<xs:annotation>
<xs:documentation>blah blah blah </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="Shape">
<xs:sequence>
<xs:element ref="angle1"/>
<xs:element ref="angle2"/>
<xs:element ref="angle3"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>`
This builds the java Triangle class with the extension base only and none of the 3 elements listed above. However if i remove the extension, the 3 elements populate after building the wsdl file. Its only when I have both the extension tag and element tag that the element stuff doesn't appear. Anyone have insight as to what is going on?

Related

XSD 0-unlimited nodes in any order

Is it possible with XSD to allow a limited set of child nodes names, but allow 0-unlimited instances of each, in any order?
So far as I can tell ns:any allows any order, but no more than one instance of each, ns:sequence requires the specified order while ns:choice limits you to only one of the list.
But I also seemingly can't just have a ns:simpleType or ns:complexType with no order indicator.
Alternatively, I could import my XML without validating against an XSD, then validate each of those required nodes against their own XSD, but I can't seem to find a way to validate an [Xml.Element] directly. Perhaps I could take each of the nodes and create a temporary [Xml.Document] from it to validate, but as far as I can tell the only way to validate XML against an XSD is when reading from a file, and writing a temporary file hundreds to thousands of times just to validate a node seems horribly inefficient.
I have spent more than a little time developing my XSD, so I hope there is an XSD based solution. But at least all this work has resulted in much more consistent XML than I would have otherwise had, and the XSD exercise provides a specification of sorts for the code I need to validate the XML. Some consolation there.
EDIT: The potential solution I have found is to make an ns:group, that contains an ns:choice that contains all the child nodes as minOccurs='0' maxOccurs='1', then reference that group where those nodes are needed with <xs:group ref="TaskGroup" minOccurs='0' maxOccurs='unbounded'/>. Still not ideal as another subtlety is in two places I need JUST the tasks (of which there are maybe 30) and in one other location I also need to allow for a node called <package> that can be interspersed with the other task nodes. At which point I have two groups where the vast majority is the same 30 tasks and the only difference is one also has a <package>. And there seems to be no way to use ns:group, ns:union and ns:choice together to get the required result. Damn you Microsoft!
Ugly, and I may still just abandon XSD and code my own validation.
EDIT: I did try using an ns:extension like this, and I get an error that The 'http://www.w3.org/2001/XMLSchema:extension' element is not supported in this context.
<xs:complexType name='TaskList'>
<xs:choice>
<xs:element name='taskCopy' type='Task_Copy' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskCreateFolder' type='Task_CreateFolder' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskDelete' type='Task_Delete' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskExecuteProgram' type='Task_ExecuteProgram' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskInstallProgram' type='Task_InstallProgram' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskInventoryHardware' type='Task_InventoryHardware' minOccurs='0' maxOccurs='unbounded'/>
<xs:element name='taskInventorySoftware' type='Task_InventorySoftware' minOccurs='0' maxOccurs='unbounded'/>
<xs:element name='taskManageAsset' type='Task_ManageAsset' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskManageNetworkLocation' type='Task_ManageNetworkLocation' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskManageManageMappedDrive' type='Task_ManageManageMappedDrive' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskManageZipFile' type='Task_ManageZipFile' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskMirror' type='Task_Mirror' minOccurs='0' maxOccurs='1'/>
<xs:element name='taskSetRegistryValue' type='Task_SetRegistryValue' minOccurs='0' maxOccurs='1'/>
</xs:choice>
</xs:complexType>
<xs:complexType name='PackageList'>
<xs:extension base="TaskList">
<xs:choice>
<xs:element name='package' type='xs:string' minOccurs='0' maxOccurs='1'/>
</xs:choice>
</xs:extension>
</xs:complexType>
So, it seems to me that, in XSD 1.0 at least, ns:choice is very limited and cannot be unioned or extended.
EDIT2: To clarify, this is a simplified example of what my XML looks like.
<packages>
<package id="ParentPackage">
<taskCopy id="SimpleTask">
<process>
<source>PATH TO... source</source>
<destination>PATH TO... destination</destination>
</process>
</taskCopy>
<package>NestedPackage</package>
<taskCopy id="ComplexTask">
<preprocess>
<taskDelete>
<process>
<path>[Product~Journals]\*</path>
</process>
</taskDelete>
</preprocess>
<process>
<source>PATH TO... source</source>
<destination>PATH TO... destination</destination>
</process>
</taskCopy>
</package>
<package id="NestedPackage">
<taskCopy id="AnotherSimpleTask">
<process>
<source>PATH TO... source</source>
<destination>PATH TO... destination</destination>
</process>
</taskCopy>
</package>
</packages>
There are 30 different Task options, and any of them can occur nested within the <preprocess> node of a Task. They can also occur in a <package>, but a package can also contain another nested <package>, which itself contains tasks and packages. Order is variable for both tasks and packages.
The goal is to not need to maintain duplicate task lists to handle the difference between what can be in a package node and what can be in a task preprocess node.
Define a complex type that contains a choice with all the optional childs and assign that complex type to the parent of all the childs.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Root" type="randomType"/>
<xs:complexType name="randomType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="a"/>
<xs:element name="b"/>
<xs:element name="c"/>
</xs:choice>
</xs:complexType>
</xs:schema>
an xml like this is then still valid
<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<b>a</b>
<a>text</a>
<b>a</b>
<b>a</b>
<b>a</b>
<b>a</b>
<b>a</b>
<a>text</a>
</Root>

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>

Element with name "Con" cannot be generated by XJC

Hello guys i have following problem when generating Java classes from XSD file. This is taken from PMML xsd file, where the element named "Con" is located. These two are the only places this element is used. Even with this smallest possible example it doesnt work.
<xs:element name="Neuron">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="Con"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Con">
<xs:complexType>
<xs:attribute name="from" type="xs:double" use="required"/>
</xs:complexType>
</xs:element>
When i try to generate classes with the name "Con" in there i get following error:
unable to write files: C:\myPathHere\build\generated\jaxbCache\PMML-4-3\org\dmg\pmml_4_3\Con.java (The handle is invalid)
Interestingly if i change the name of the element to anything else it is working without problem and all classes are generated correctly. Is there something im missing here? Sadly could not find anything related to name "Con" being excluded from valid element names in XSD for JAXB java class generation.
Thanks for any ideas.
Con is a reserved word for windows. You can't create Con.txt itself on windows. What you can do is customize the binding, give a different file name and use the #XmlElement(name="Con") annotation
See Class Binding Declarations to customize the classname

Group name attribute invalid

I am trying to create a Group.
Based on your documentation, I can create a "name" associated with that group in the source editor but I can't through the GUI. If I try and create one manually in the source it says that "name is not a valid attribute for group".
What am I doing wrong? I would like to add this for grouping like items.
<xs:schema elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="myElm">
<xs:complexType>
<xs:sequence>
<xs:group name="myGroup" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Only the root element can have a name. When you reference it for inclusion, the name attribute is not valid.
Adding a name attribute in where is is referenced (i.e. ) will result in the error "name is not a valid attribute for group".
This conforms to the W3C XSD Standard. Using the UI it is not possible to perform this action, as name is not available, however you can do this by changing the source code.
<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio - 30 Day Trial Edition 7.0.0.604 (http://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:group name="myGroup" />
<xs:element name="myElm">
<xs:complexType>
<xs:sequence>
<xs:group ref="myGroup" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
You can then add a particle (sequence/choice/all) to the group definition anb build up groups of elements that can be re-used as a block.

Adding a new operation to existing webservice

Can anyone suggest a good tutorial on how to add new operations to already existing webservices?I referred many tutorials but most are discussing about creating a new wsdl and then changing it.I also referred the following and when i tried it, the design view is not showing the names of existing ports.PLZ help by giving me suitable advice.
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.wst.wsdl.ui.doc.user%2Ftasks%2Ftcrtwsdl.html
If the web service already exists you can edit the existing interface and code behind to add the new operations.
Once you have done this you should be able to use a tool to generate a new WSDL which can be deployed along with your updated service.
The following tool; Java2WSDL should help, http://axis.apache.org/axis/java/user-guide.html#Java2WSDL:_Building_WSDL_from_Java
Hope this helps.
Add an element in XSD file and map local part to new method in endpoint controller. getCountryRequest is existing operation in below XSD and I have added getCountryByCurrencyRequest.
<xs:element name="getCountryRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getCountryResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="country" type="tns:country" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getCountryByCurrencyRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>