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.
Related
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.
I'm trying to use the Simplify plugin to replace a complex property with a set of simpler ones. I made it working following the plugin's manual. But I can't change the original schema, so I have to use an external bindings.xjb. And it gives me all sort of errors. Does somebody have a working example of a similar thing?
Original XSD:
<xs:schema id="messages"
elementFormDefault="qualified"
version="Exchange2010_SP2"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schemas.microsoft.com/exchange/services/2006/messages">
<xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/types" schemaLocation="types.xsd"/>
...
<xs:complexType name="ArrayOfResponseMessagesType">
<xs:choice maxOccurs="unbounded">
<xs:element name="CreateItemResponseMessage" type="m:ItemInfoResponseMessageType"/>
<xs:element name="DeleteItemResponseMessage" type="m:ResponseMessageType"/>
<xs:element name="GetItemResponseMessage" type="m:ItemInfoResponseMessageType"/>
...
</xs:choice>
</xs:complexType>
Modified XSD that works for me:
<xs:schema id="messages"
elementFormDefault="qualified"
version="Exchange2010_SP2"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:extensionBindingPrefixes="simplify"
targetNamespace="http://schemas.microsoft.com/exchange/services/2006/messages">
<xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/types" schemaLocation="types.xsd"/>
...
<xs:complexType name="ArrayOfResponseMessagesType">
<xs:choice maxOccurs="unbounded">
<xs:element name="CreateItemResponseMessage" type="m:ItemInfoResponseMessageType">
<xs:annotation>
<xs:appinfo>
<simplify:as-element-property/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="DeleteItemResponseMessage" type="m:ResponseMessageType"/>
<xs:element name="GetItemResponseMessage" type="m:ItemInfoResponseMessageType"/>
...
</xs:choice>
</xs:complexType>
My bindings.xjb (that I want to use instead of changing the schema):
<bindings version="2.1"
xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
extensionBindingPrefixes="simplify">
<bindings schemaLocation="../wsdl/messages.xsd" node="/xs:schema/xs:complexType[#name='ArrayOfResponseMessagesType']/xs:choice/xs:element[1]">
<xs:annotation>
<xs:appinfo>
<simplify:as-element-property/>
</xs:appinfo>
</xs:annotation>
</bindings>
</bindings>
My current exception
org.xml.sax.SAXParseException: Unsupported binding namespace "http://www.w3.org/2001/XMLSchema". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?
Ok, I figured this out. Here is the configuration that made it working:
<bindings version="2.1"
xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
extensionBindingPrefixes="simplify">
<bindings schemaLocation="../wsdl/messages.xsd" node="/xs:schema/xs:complexType[#name='ArrayOfResponseMessagesType']/xs:choice/xs:element[1]">
<simplify:as-element-property/>
</bindings>
</bindings>
That simple.
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>
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>
I have this xsd:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns="http://myschema.com/schema"
targetNamespace="http://myschema.com/schema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="aType" mixed="true">
<xs:group ref="aElements" minOccurs="0" maxOccurs="unbounded"/>
</xs:complexType>
<xs:group name="aElements">
<xs:choice>
<xs:element name="a" type="aType"/>
</xs:choice>
</xs:group>
<xs:element name="b">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="aElements"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
and I try to validate this xml document against it:
<?xml version="1.0" encoding="utf-8" ?>
<b xmlns="http://myschema.com/schema">
<a/>
</b>
However, Visual Studio 2008's xml validator complains about the <a> element:
The element 'b' in namespace 'http://myschema.com/schema' has invalid child element 'a' in namespace 'http://myschema.com/schema'. List of possible elements expected: 'a'.
What is the problem?
Edit: Oops, when dumbing down the example I caused forgot to make the element optional inside the element, causing infinite recursion. The problem is still there with this mod, though.
ANSWER: The answer was that the xs:schema tag should include the elementFormDefault="qualified" attribute.
you define aElements with aType, and aType with aElements. i'm not an xsd expert, but how is that supposed to work?
You could make your life much easier using an editor for XSD development. We've been using Liquid XML Studio for ages, it makes life much easer.