When I define the fields of a contract in XSD I define a list field with maxOccurs= and minOccurs>0.
Can i declare the XSD in such a way that when the request is received the fields with occurs have occurance number?
e.g.
I hope i make my self clear.
<xsd:complexType name="FieldNameType">
<xsd:sequence>
<xsd:element name="FieldName" type="FieldNameType" minOccurs="1" maxOccurs="8"/>
</xsd:sequence>
</xsd:complexType>
and when the request is send i get something like:
<FieldName_1></FieldName_1>
<FieldName_2></FieldName_2>
<FieldName_3></FieldName_3>
Thanks in advance!
I found a work-around! As i saw i can iterate through the same nodes in an XSLT file.
Related
I have a SOAP URL with one of the input parameters of enumerated type as below. With SOAPUI I'm just able to remove the ? mark and able to execute the request successfully. <urn:Comm_Source></urn:Comm_Source>
I created client code using wsimport and it creates the input method parameter as CommSourceType object. If I pass null for this value the web service fails.
<xsd:element maxOccurs="1" minOccurs="0" name="Comm_Source" nillable="false" type="s0:Comm_SourceType"/>
There is a lack of information for the complete answer (eg the whole wsdl/xsd or what means: If I pass null for this value the web service fails.).
In general:
null is not the same as an empty string.
<urn:Comm_Source></urn:Comm_Source> - is an empty string
<urn:Comm_Source xsi:nil="true" /> - is a null value (xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance")
the specified element <xsd:element maxOccurs="1" minOccurs="0" name="Comm_Source" nillable="false" type="s0:Comm_SourceType" /> does not support null because there is nillable="false".
The element can either be omitted or an empty string can be written in it.
I am trying to generate a bunch of xml annotated pojos. To do this I have all my xsd files in the resource folder of my project (they are from the polycom rmx sdk, RmxSdkApiV7_8-EMA_EMA-V7_8_0_303). I then right click on each one (over 150 of them) go to generate and click JAXB classes. I pick the project and give it a namespace than finish the wizard. After doing this there is a warning that any newly generated classes will override existing ones. This is my problem, because some commonly used objects will have different definitions in different xsd files. So when the override happens whatever was defined is lost.
So for example, response_trans_conf.xsd defines GET as
<xsd:element name="GET">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="CONFERENCE" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Where as another schema file like trans_conf_2.xsd defines GET as
<xsd:element name="GET">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="ID"/>
<xsd:element ref="OBJ_TOKEN"/>
<xsd:any processContents="skip" minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
So I'll end up with a Get object that looks like
public class GET {
#XmlElement(name = "CONFERENCE")
protected ConferenceContent conference;
OR (respectively)
public class GET {
#XmlElement(name = "ID", required = true)
protected BigInteger id;
#XmlElement(name = "OBJ_TOKEN", required = true)
protected String objtoken;
#XmlAnyElement
protected List<Element> any;
What I need is an object that a combination of both. Like I said there are over 150 xsd files in this sdk. So this problem is multiplied by few other common objects.
FYI at the same time of wanting a combined class rather then an overridden one Im hoping the solution would also prevent duplicates some how.
due to lack of answers I have implemented a workaround which is to manually add the missing/needed members.
Im sure the comment above by ulab would work as well but I really do not want to edit the xsd's
The other option I see but did not implement is a wrapper. extending these common classes to have all the members in another layer above the sdk's generated file. that would ensure the sdk doesnt need to be touch even when there is a new version and a new generation of files.
I am trying to create a dynamic temp table and dataset from an external DTD file. I trying to simplify some xml code POST/GET and take advantage of the READ/WRITE XML functions with datasets.
I referenced the documentation for READ-XMLSCHEMA and it seems to do what I need however, I keep getting errors and can't figure out what I am doing wrong.
Here is a snippet
DEFINE VARIABLE hTable AS HANDLE NO-UNDO.
DEFINE VARIABLE retOK AS LOGICAL NO-UNDO.
DEFINE VARIABLE cSourceType AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE lOverrideDefaultMapping AS LOGICAL NO-UNDO.
DEFINE VARIABLE cFieldTypeMapping AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVerifySchemaMode AS CHARACTER NO-UNDO.
CREATE TEMP-TABLE hTable.
ASSIGN
cSourceType = "file"
cFile = "http://xml.cxml.org/schemas/cXML/1.2.025/InvoiceDetail.dtd"
lOverrideDefaultMapping = NO
cFieldTypeMapping = ?
cVerifySchemaMode = ?.
retOK = hTable:READ-XMLSCHEMA (cSourceType,
cFile,
lOverrideDefaultMapping,
cFieldTypeMapping,
cVerifySchemaMode).
Does anyone know how I can achieve this using Openedge 10.1C.
Thanks
Errors that i am receiving...
---------------------------
Error
---------------------------
Error reading XML file 'http://xml.cxml.org/schemas/cXML/1.2.025/InvoiceDetail.dtd'. (13035)
---------------------------
OK
---------------------------
---------------------------
Error
---------------------------
READ-XML encountered an error while parsing the XML Document: FATAL ERROR: file 'http://xml.cxml.org/schemas/cXML/1.2.025/InvoiceDetail.dtd', line '15', column '2', message 'Expected comment or CDATA'. (13064)
---------------------------
OK
---------------------------
I think Progress is looking for an XSD file -- not a DTD. Looking at your link and comparing it to a working XSD file that I use they look nothing alike.
An example of XSD that Progress will like looks like this:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:prodata="urn:schemas-progress-com:xml-prodata:0001">
<xsd:element name="tt_DBId" prodata:proTempTable="true">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="tt_DBIdRow" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="dbidLogName" type="xsd:string" nillable="true" prodata:label="DB Logical Name"/>
<xsd:element name="dbidPhysName" type="xsd:string" nillable="true" prodata:label="DB Physical Name"/>
<xsd:element name="dbidHost" type="xsd:string" nillable="true" prodata:label="DB Host Name"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:unique name="dbidLogName-idx" prodata:primaryIndex="true">
<xsd:selector xpath=".//tt_DBIdRow"/>
<xsd:field xpath="dbidLogName"/>
</xsd:unique>
</xsd:element>
</xsd:schema>
Also, 10.1C isn't going to have the best compatibility. That's a really old release that hasn't seen an update in a long time. A lot of improvements were made in the late 10.2B service packs and OE11.4 or 11.5 should have even better support.
I'm getting org.xml.sax.SAXParseException's when trying to map a one-to-one relation in JPA
Everything is working fine until I change from
<transient name="testCase"/>
to:
<attributes>
..
<one-to-one name="testCase">
<join-column name="test_case_id"/>
</one-to-one>
..
</attributes>
Gives error:
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'one-to-one'. One of '{"http://java.sun.com/xml/ns/persistence/orm":many-to-many, "http://java.sun.com/xml/ns/persistence/orm":embedded, "http://java.sun.com/xml/ns/persistence/orm":transient}' is expected.
I don't understand what the exception message means. Why is these expected for this?
Your orm.xml was not valid according to it's XML Schema. The problem was that the element 'one-to-one' is part of a sequence, which means that the contained elements MUST respect the defined order.
An abstract of the Schema:
<xsd:complexType name="attributes">
<xsd:sequence>
...
<xsd:element name="basic" .../>
<xsd:element name="version" .../>
<xsd:element name="many-to-one" .../>
<xsd:element name="one-to-many" .../>
<xsd:element name="one-to-one" .../>
<xsd:element name="many-to-many" .../>
...
</xsd:sequence>
</xsd:complexType>
see the whole Schema at enter link description here
I found the problem. I moved the one-to-one section so it was before the many-to-many section. Don't know why this happened. The two sections does not have anything in common.
Short version:
I'm trying to write an XSD that will validate my SOAP service's responses. I feel compelled to just import http:// schemas.xmlsoap.org/soap/envelope/ instead of redefining the SOAP elements like Envelope, Head, and Body, but that xmlsoap.org schema definition of Body is too broad for my use--as soon as I import the SOAP Schema, suddenly my XSD (that I've carefully tailored to my service) validates all SOAP messages.
How should I handle the definition of the SOAP envelope, head, body in my XSD?
I suspect the problem is that I'm trying to re-use other schemas that I shouldn't be trying to re-use. Certainly, those Schemas for SOAP are intended to define what (all) SOAP messages should look like. And maybe I just need to define in my schema what I want my particular soap body to look like.
I might have just answered my own question. Maybe someone has a different solution?
Long version:
I'm having a little trouble authoring an XSD to describe the response message from one of my SOAP services.
Here's an example response from my service that I'm trying to validate:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<helloResponse xmlns="http://justinfaulkner/wsdl/1.0">
<Message>Hello, Justin!</Message>
<Message>Your lucky numbers are: 329, 9</Message>
</helloResponse>
</soap:Body>
</soap:Envelope>
My goal is to validate responses from my service with an XSD.
So, I hand-authored an XSD that describes all the types that belong in my service's soap:Body
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://justinfaulkner/wsdl/1.0" xmlns:tns="http://justinfaulkner/wsdl/1.0">
<xsd:complexType name="helloResponseType">
<xsd:sequence>
<xsd:element name="Message" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="helloResponse" type="tns:helloResponseType"/>
</xsd:schema>
When I tried to validate the example response (first XML snippet) with the Schema (2nd snippet) using PHP's DOMDocument::schemaValidateSource() functionality, the validator pointed out my first obvious mistake:
Element 'soap:Envelope': No matching global declaration available
"Oops, duh," I thought, "Those elements are defined in SOAP's namespace, so I need to import SOAP's XSD."
So I edited my XSD and added an import:
<xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/" schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"/>
And it worked! DOMDocument::schemaValidateSource returns true when I validate the soap response with the XSD.
Then, as a sanity check, I took a different soap response XSD I had lying around:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://justinfaulkner/wsdl/1.0" xmlns:tns="http://justinfaulkner/wsdl/1.0">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/" schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"/>
<xsd:complexType name="OtherServiceResponseType">
<xsd:all>
<xsd:element name="CompletionCode" type="xsd:string"/>
<xsd:element name="ResponseMessage" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:element name="OtherServiceResponse" type="tns:OtherServiceResponseType"/>
</xsd:schema>
And I tried to validate my soap response with this completely unrelated Schema...
And the schema that, at first glance, doesn't describe this message at all, also validates the soap response.
Then I realize that XSD's Schema must be the reason the response is validating against these two different schemas. The SOAP schema I'm importing from http://schemas.xmlsoap.org/soap/envelope/ defines the Body element to be:
<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>
Which allows the contents of the Body tag to be basically anything.
That makes sense, the purpose of XSD's XSD is to define what ALL XSDs should look like, not just mine.
So my question is, how should I build an XSD to validate these SOAP responses, reusing existing SOAP XSDs if possible?
Here's the direction I've been pursuing...
I guess I could throw xmlsoap.org's XSD schema out the window and redefine Envelope and Body myself, specifying exactly what should show up in the Body element. But I feel like I'll end up basically having a copy of all the soap elements inside my own XSD, with a slightly different Head and Body definition, and that feels like a violation of DRY.
Is there a way I can import xmlsoap.org's XSD but then override the definition of soap:Body from inside my XSD?
You should use a SOAP web service framework to do that. There are many for various programming languages listed on the wikipedia page. You write a WSDL to specify your web service API, and in which you import your XSD to define the payload formats (contract-first approach). Use the wsdl2xxx tool provided by the framework to generate the API stub. You write the API implementation code. The framework will take care of the rest (processing the SOAP messages and binding to your implementation code).