Creating WSDL from two XSD using import - xsd

I have the following WSDL
The message part elements aren't valid.The elements "request:OTA_VehAvailRateRQ" and "response:OTA_VehAvailRateRS" are not defined in the namespaces but all imports and targetNamespaces do not seem have problems.
I isn't able to see the problem :(
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions
name="OTA_VehAvailRate"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.karve.org/OTA_VehAvailRate/"
xmlns:tns="http://www.karve.org/OTA_VehAvailRate/"
xmlns:request="http://www.karve.org/OTA_VehAvailRateRequest/"
xmlns:response="http://www.karve.org/OTA_VehAvailRateResponse/">
<wsdl:types>
<xs:schema targetNamespace="http://www.karve.org/OTA_VehAvailRate/">
<xs:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="OTA_VehAvailRateRQ.xsd" />
<xs:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="OTA_VehAvailRateRS.xsd" />
</xs:schema>
</wsdl:types>
<!-- These messages fails in the wsdl:part element -->
<wsdl:message name="OTA_VehAvailRateRequest">
<wsdl:part element="request:OTA_VehAvailRateRQ" name="parameters"/>
</wsdl:message>
<wsdl:message name="OTA_VehAvailRateResponse">
<wsdl:part element="response:OTA_VehAvailRateRS" name="parameters"/>
</wsdl:message>
........ Rest of WSDL ......
This one of my XSD (request)
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.opentravel.org/OTA/2003/05"
targetNamespace="http://www.opentravel.org/OTA/2003/05"
elementFormDefault="qualified" version="2.000" id="OTA2010A">
<xs:element name="OTA_VehAvailRateRQ">
<xs:complexType>
.........
</xs:complexType>
</xs:element>
</xs:schema>

Imports and targetNamespaces do seem to have problems.
You define the following namespace in WSDL:
xmlns:request="http://www.karve.org/OTA_VehAvailRateRequest/"
But in the XSD and the import you have the following namespace:
<xs:import namespace="http://www.opentravel.org/OTA/2003/05"
schemaLocation="OTA_VehAvailRateRQ.xsd" />
So the namespace of the request:OTA_VehAvailRateRQ does not mache the namespace of the element OTA_VehAvailRateRQ in your schema.

Related

SOAPUI: Found nothing to import in [file ...\test.wsdl]

Could anyone tell me how I fix this XSD and WSDL:
XSD:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="testRequest">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="BETA"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
WSDL:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="test"
targetNamespace="http://www.examples.com/wsdl/test"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.examples.com/wsdl/test"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" namespace="http://www.examples.com/wsdl/test">
<xs:import namespace="http://www.examples.com/wsdl/test" schemaLocation="../wsdl/testRequest.xsd"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="testRequest">
<wsdl:part name="testRequest" element="testsRequest"/>
</wsdl:message>
</wsdl:definitions>
SOAPUI ERROR:
Found nothing to import in [file ...\test.wsdl]
How can I solve this problem?
You are missing some elements in your WSDL.
Basically a WSDL consist of;
Definitions,
Type,
Message,
Port Type,
Binding,
Service and
Port
The easiest way to understand this is to follow an example like https://www.tutorialspoint.com/wsdl/wsdl_example.htm
Try loading that in your SoapUI. Confirm that everything works and then start playing around with the various elements to see what they do.

import in XSD and its implementation

I have 2 separate XSDs with some common attributes. I want to create another XSD and put all my common attributes in the separate XSD and import them in the 2 XSDs i have already rather than repeating them or duplicating them in both the XSDs.
Is there any reference for such implementation?
We do it like this:
Shared "library" xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.common.namespace/" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.common.namespace/">
<xs:attribute name="ACommonAttribute" type="xs:float" default="1.7"/>
</xs:schema>
Left xsd with same target namespace:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.common.namespace/" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.common.namespace/">
<xs:include schemaLocation="Common.xsd"/>
<xs:element name="MyLeftElement">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute ref="ACommonAttribute"/>
</xs:complexType>
</xs:element>
</xs:schema>
Right xsd with different target namespace (needs an Import instead if an Include statement)
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://another.namespace/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:libs="http://www.common.namespace/" targetNamespace="http://another.namespace/">
<xs:import namespace="http://www.common.namespace/" schemaLocation="Common.xsd"/>
<xs:complexType name="RightComplexType">
<xs:sequence>
<xs:element name="Bit">
<xs:complexType>
<xs:attribute ref="libs:ACommonAttribute"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>

XSD schema: using multiple xmime with expectedContentTypes

I've a XSD \ schema with an element (as shown below). This element is expected to have either CSV or XML data. I am not sure what expectedContentTypes to use. I can think of the following but not sure:
text/*
*/*
<xs:element name="Data" type="xs:base64Binary" xmime:expectedContentTypes="text/*"/>
or is there any other way? like
"text/csv;text/xml"
Strictly speaking, your element Data type should be derived from xmime:base64Binary. text/* is correct, or text/csv,text/xml - a comma should be used instead.
However, why binary encoding when you're shipping text? One thing to consider is the size of the message, with base64 encoding your result will register about 30% overhead.
Have you considered this XSD:
<?xml version="1.0" encoding="utf-8" ?>
<!--W3C Schema generated by QTAssistant/W3C Schema Refactoring Module (http://www.paschidev.com)-->
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Data">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="skip"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Any XML below will work equally; XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns="http://tempuri.org/XMLSchema.xsd">
<something></something>
</Data>
CSV:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns="http://tempuri.org/XMLSchema.xsd">
A,B,B
1,2,3
</Data>
In other words, you could have the XML, the CSV, or both. If you don't want both, there are tricks to ensure stronger data typing.

Need help creating XML file from XSD schema

I am learning to work with XML schemas.
I want to create an XML file based on the "address.xsd" schema file :
"address.xsd"
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema
elementFormDefault="qualified"
targetNamespace="com.namespace.address"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="AddressDetails">
<xs:sequence>
<xs:element name="building" type="xs:string" />
<xs:element name="street" type="xs:string" />
<xs:element name="city" type="xs:string" />
<xs:element name="country" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
address.xml
<?xml version="1.0" encoding="utf-8"?>
<a:AddressDetails
xmlns:a="com.namespace.address"
xsi:schemaLocation="D:/Prac/XML/address.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<a:building>Crosswords</a:building>
<a:street>MainStreet</a:street>
<a:city>LA</a:city>
<a:country>USA</a:country>
</a:AddressDetails>
Iam not getting why this is not working.
Actually XSD is used to validate xml not for XML generation
Ok, i have figured out the problem. There was some problem with the namespaces. Here i am posting the "address.xsd" schema file along with the valid "address.xml".
address.xsd
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema elementFormDefault="qualified" targetNamespace="com.namespace.address" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="AddressDetails">
<xs:sequence>
<xs:element name="building" type="xs:string" />
<xs:element name="street" type="xs:string" />
<xs:element name="city" type="xs:string" />
<xs:element name="country" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="address" xmlns:q1="com.namespace.address" type="q1:AddressDetails" />
</xs:schema>
address.xml
<?xml version="1.0" encoding="utf-8"?>
<a:address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="com.namespace.address address.xsd" xmlns:a="com.namespace.address">
<a:building>Crosswords</a:building>
<a:street>Main Street</a:street>
<a:city>LA</a:city>
<a:country>USA</a:country>
</a:address>

Generating closing tag for empty elements using XMLBeans

I have following xsd :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="employee" type="employeeType"/>
<xs:complexType name="employeeType">
<xs:sequence>
<xs:element type="xs:string" name="name"/>
<xs:element type="xs:int" name="age"/>
<xs:element type="xs:string" name="address"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
If i set value only for Name i.e
EmployeeDocument request=EmployeeDocument.Factory.newInstance();
EmployeeType emp=EmployeeType.Factory.newInstance();
emp.setName("Name");
request.setEmployee(emp);
Then XMLBeans generating following xml:
<employee>
<name>Name</name>
</employee>
But i need a following kind of xml to be generated ,means closing tags </> for all elements whose values are not set in program :
<employee>
<name>Name</name>
<age/>
<address/>
</employee>
well , XMLBeans generating <address/> if i set an empty string i.e emp.setAddress("");
Is there any way we could meet such requirement using XMLBeans , without setting empty string.
And more over we could not set empty string for element age which is of type int .
Any help would be appreciated.
The XMLSchema way to do this is add nillable="true" to your age and address elements. When you recompile the xsd with XMLBeans, you will have .setNilAge() and .setNilAddress() methods. The generated xml will look like:
<employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<name>Name</name>
<age xsi:nil="true"/>
<address xsi:nil="true"/>
</employee>
By the way, it is better to build up your document using .addNewEmployee() instead of .setEmployee() if possible. This avoids copying the employee instance into the document which is more expensive.

Resources