Im in the process of writing a wsdl file for an existing system. I'd like to add comments to generated requests.
For instance this:
<xsd:simpleType name="coffeetype">
<xsd:restriction base="xsd:integer">
<!--0=likescoffee,1=doesnotlikecoffe-->
<xsd:enumeration value="0" />
<xsd:enumeration value="1" />
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="CoffeeRequestInput" nillable="false" type="tns:coffeetype" />
Should look like this in the generated request: (eg. when loading the WSDL in SoapUI)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="https://example.com/some.wsdl">
<soapenv:Header/>
<soapenv:Body>
<!--0=likescoffee,1=doesnotlikecoffe-->
<wsdl:CoffeeRequestInput>0</wsdl:CoffeeRequestInput>
</soapenv:Body>
</soapenv:Envelope>
I was able to see these comments when opening the WSDL but not when generating a request from that WSDL.
Already looked into annotations but I wasn't able to use them to create the result I wanted. (Probably an error on my side)
In short you cannot create documentation in requests as you would like to. However you can generate documentation from your WSDL that can be be very useful. By using the "xsd:documentation" tag you can add documentation directly to the elements.
For example
<xsd:simpleType name="coffeetype">
<xsd:restriction base="xsd:integer">
<xsd:enumeration value="0" />
<xsd:enumeration value="1" />
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="CoffeeRequestInput" nillable="false" type="tns:coffeetype">
<xsd:annotation>
<xsd:documentation>
This object is the CoffeeRequestInput object is an Enumeration which can be used to determine is the user sending the request likes coffee or not.
Valid values for the enumeration is as follows:
0 = like coffee
1 = does not like coffee (probably a user not a programmer making a request).
Some other things that you need to document goes here.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
You can then use software such as Altova StyleForce, LiquidXML and OxyGen to generate PDF, Word documents or HTML pages which shows the SOAP services and operations with all your comments included.
If you feel up to it you can write your own XLST to transform your WSDL and XSD's into a neat HTML page which documents you interfaces as well. The best part about this is that when you update the WSDL with new operations and so on that the documentation is updated as well.
Related
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.
We have a XML file that is on somewebsite and looks in a way like this (confidential parts stripped)
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="https://somewebsite.com/crm/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Accounts</title>
<id></id>
<updated>2016-02-04T08:36:56Z</updated>
<link rel="self" title="Accounts" href="Accounts" />
<entry>
<title type="text"></title>
<updated>2016-02-04T08:36:56Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:Type>A</d:Type>
<d:UniqueTaxpayerReference m:null="true" />
<d:VATLiability m:null="true" />
<d:VATNumber m:null="true" />
<d:Website m:null="true" />
</m:properties>
</content>
</entry>
<link rel="next" href="https://somewebsite.com/Accounts?$skiptoken=guid'ee6bc390-a8ac-4bbd-8a4d-0a1f04ab9bd3'" />
</feed>
We use the new Rest connector to get the data out of this XML file.
The XML has pagination and every 60 entries you can load the next 60 with the link at the bottom of this xml file.
The problem i have is when, in the REST connector, we want to enable pagination with these setting:
Pagination Type: Next URL
Next URL field path:
/*[name()="feed"]/*[name()="link"][contains(#rel,"next")]/#href
It doesn't seem to work...
side note: the XML file has namespaces so i need to target the elements this way instead of /feed/link/...
I'm using Xpath syntax to target the link href, but maybe this is not the way to go? Or maybe the REST connector isn't using Xpath syntax?
Really hope someone can help me!
Actually it turns out that this seems to be due to a "bug" in the "Qlik REST Connector 1.0" so the pagination doesn't work.
But there is a fix for it:
1) Make sure that the Qlik REST Connector 1.0 connect dialog box has the NextUrl set to:
feed/link/attr:href
2) When the SQL has been generated after using the SELECT-button and going through the wizard you have to modify the sub-SELECT that reads like this:
.....
(SELECT
"attr:rel" AS "rel",
"attr:title" AS "title",
"attr:href" AS href,
"__FK_link"
FROM "link" FK "__FK_link"),
.....
On line 05 you will have to remove the text AS href.
So it should look like this:
.....
(SELECT
"attr:rel" AS "rel",
"attr:title" AS "title",
"attr:href",
"__FK_link"
FROM "link" FK "__FK_link"),
....
3) Find the LOAD statement that loads from this sub-select with a RESIDENT [MasterREST further down in the load script and make sure that the reference to href is changed to [attr:href] - or else you will get an error message while loading.
Should look like this after the change:
[link]:
LOAD [rel],
[title],
[attr:href],
[__FK_link] AS [__KEY_feed]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_link]);
This worked for me:
/*[name()='feed']/*[name()='link'][#rel='next']/#href
Yours should also work actually, maybe whatever you are using does not agree with double quotes instead of single quotes.
I have a web application using Jersey, and I would like to describe its' REST API with WADL.
Jersey generates .wadl file by default, but it does not contain objects (some of my REST calls send/return objects). Actually, I get something like this:
<method id="save" name="POST">
<request>
<representation mediaType="application/json"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
How can I create .wadl that describes also objects?
Acceptable and returned types are described by XML Schema only when you are accepting/returning application/xml type. There is no generally accepted description of JSON types or structures, so WADL generated from Jersey doesn't contain related description (simply because there is no standard way how to achieve that).
I'm working on a SOAP webservice which features many inputfields using enumeration restrictions.
These enumerations are much like an HTML select/option setup; I expect a certain value to be returned but the label of that value should be exposed using the WSDL as well.
An example: the client wishes to add an insurance policy regarding his/her house and thus needs to specify the type of building involved.
<xsd:restriction base="xsd:string">
<xsd:enumeration value="00001" />
<xsd:enumeration value="00002" />
<xsd:enumeration value="00003" />
</xsd:restriction>
However, the client does not yet understand what these values 1, 2 and 3 are. So, something like this:
<xsd:restriction base="xsd:string">
<xsd:enumeration value="00001" label="Brick and mortar" />
<xsd:enumeration value="00002" label="Straw" />
<xsd:enumeration value="00003" label="Aircastle" />
</xsd:restriction>
would be great for the client to be used to display these labels to the consumer.
Is there any standard WSDL annotation/syntax for this construction?
Is there any standard WSDL annotation/syntax for this construction?
I'm afraid not. The XML Schema enumeration is used to constrain a value to be within a specified set of possible values. When your client sends you the request, the element with the restriction type will only be allowed to have (in your case) a value of 00001, 00002 or 00003 or it won't be valid.
The restriction only specifies the values, you can't add labels. You could at best add an <annotation> but that would be just documentation. In the client UI, it would be the responsibility of each client to say that 00001 is actually "Brick and mortar" and that 00002 is "Straw" etc.
If you don't want to do that, and instead want to also return labels, then you need a slightly more complex object, maybe something like this:
<option>
<key>00001</key>
<label>Brick and mortar</label>
</option>
You provide a label and you restrict the key with a schema like:
<xsd:simpleType name="ValuesType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="00001" />
<xsd:enumeration value="00002" />
<xsd:enumeration value="00003" />
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="OptionType">
<xsd:sequence>
<xsd:element name="key" type="ValuesType" />
<xsd:element name="label" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
You can return a list of options to the clients and they can present it in the interface with key as value and label as the text of options in <select> inputs, while on the request you will get back the selected value (i.e. the selected key).
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).