undefined complextype is used as a base for complex type extension - visual-studio

What is the problem in my WSDL file? The Visual Studio complains about an undefined complex type.
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://osmc.synium.com/services/presence" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns2="http://types.osqq.syqq.com" xmlns:impl="com.syqq.osqq.services.presence" xmlns:intf="com.syqq.osqq.services.presence" targetNamespace="com.syqq.osqq.services.presence" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://types.osqq.syqq.com">
<xsd:import namespace="http://osqq.syqq.com/services/presence" />
<xsd:import namespace="com.syqq.osqq.services.presence" />
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:complexType name="SoapBinaryMessage" abstract="true">
<xsd:sequence>
<xsd:element name="data64" nillable="true" type="xsd:string" />
<xsd:element name="version" nillable="true" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://osmc.synium.com/services/presence">
<xsd:import namespace="com.syqq.osqq.services.presence" />
<xsd:import namespace="http://types.osqq.syqq.com" />
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:complexType name="PresenceStatusBinary">
<xsd:complexContent mixed="false">
<xsd:extension base="tns2:SoapBinaryMessage">
<xsd:sequence />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
...
</wsdl:types>
Any ideas?
The problem occurs in line xsd:extension base="tns2:SoapBinaryMessage

You're missing the prefix declaration for tns2; this needs to be added somewhere such that it'll be in scope for the <xsd:extension base="tns2:SoapBinaryMessage"> node (the best place as far as I am concerned might be the second xsd:schema declaration):
xmlns:tns2="http://types.osqq.syqq.com"

Related

getting error "results in empty target node" while selecting multiple nodes

I have an WSDL like below
<wsdl:definitions targetNamespace="http://pk/training/basit/webservice/message/lmsapi/serviceoperations">
<wsdl:types>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://pk/training/basit/webservice/message/lmsapi/serviceoperations">
<xsd:import namespace="http://trainingplan.types.lmsapi.message.webservice.basit.training.pk"/>
...
<xsd:element name="CreateTrainingPlanRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="TrainingPlans" type="ns0:TrainingPlans"/>
</xsd:sequence>
<xsd:attribute name="customerCode" type="xsd:string" use="required"/>
<xsd:attribute name="key" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="CreateTrainingPlanResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="ResponseTrainingPlans" type="ns0:ResponseTrainingPlans"/>
</xsd:sequence>
<xsd:attribute name="transactionResult" type="TransactionResultType" use="required"/>
<xsd:attribute name="transactionResultMessage" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="AssignTrainingPlanToLearnerRequest">
...
</xsd:element>
....
</wsdl:definitions>
Now i want to select all three elements with name attributes using XPath. When i did the following i get the value
<jaxb:bindings schemaLocation="http://localhost:8080/lms/service/lms-api/lmsApi.wsdl" node="/wsdl:definitions/wsdl:types/xsd:schema[#targetNamespace='http://pk/training/basit/webservice/message/lmsapi/serviceoperations']/xsd:element[#name='CreateTrainingPlanRequest']">
but when i try to select multiple nodes, like
<jaxb:bindings schemaLocation="http://localhost:8080/lms/service/lms-api/lmsApi.wsdl" node="/wsdl:definitions/wsdl:types/xsd:schema[#targetNamespace='http://pk/training/basit/webservice/message/lmsapi/serviceoperations']/xsd:element[#name='CreateTrainingPlanRequest' and #name='CreateTrainingPlanResponse' and #name='AssignTrainingPlanToLearnerRequest']">
then i get the following error
com.sun.istack.SAXParseException2: XPath evaluation of "/wsdl:definitions/wsdl:types/xsd:schema[#targetNamespace='http:/pk/training/basit/webservice/message/lmsapi/serviceoperations']/xsd:element[#name='CreateTrainingPlanRequest' and #name='CreateTrainingPlanResponse' and #name='AssignTrainingPlanToLearnerRequest']" results in empty target node
why i am getting empty nodes. What is wrong with my XPath expression ?
Thanks
Edit :
--------------------------------
<jaxb:bindings schemaLocation="http://localhost:8080/lms/service/lms-api/lmsApi.wsdl" node="/wsdl:definitions/wsdl:types/xsd:schema[#targetNamespace='http://pk/training/basit/webservice/message/lmsapi/serviceoperations']/xsd:element[#name='CreateTrainingPlanRequest' or #name='CreateTrainingPlanResponse' or #name='AssignTrainingPlanToLearnerRequest']">
<jaxb:schemaBindings>
<jaxb:package name="pk.training.basit.webservice.messages.lmsapi.serviceoperations.trainingplan" />
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="http://localhost:8080/lms/service/lms-api/lmsApi.wsdl" node="/wsdl:definitions/wsdl:types/xsd:schema[#targetNamespace='http://pk/training/basit/webservice/message/lmsapi/serviceoperations'](/xsd:element[#name='AddCustomerRequest']) and (/xsd:element[#name='AddCustomerResponse'])">
<jaxb:schemaBindings>
<jaxb:package name="pk.training.basit.webservice.messages.lmsapi.serviceoperations.customer" />
</jaxb:schemaBindings>
</jaxb:bindings>
When you say
<jaxb:bindings schemaLocation="http://localhost:8080/lms/service/lms-api/lmsApi.wsdl"
node="/wsdl:definitions/wsdl:types/xsd:schema[
#targetNamespace='http://pk/training/basit/webservice/message/lmsapi/serviceoperations'
]/xsd:element[#name='CreateTrainingPlanRequest' and #name='CreateTrainingPlanResponse'
and #name='AssignTrainingPlanToLearnerRequest']">
you are asking for any xsd:element for which the #name attribute has three different values, on the same element. That's not possible. Maybe instead you want
<jaxb:bindings schemaLocation="http://localhost:8080/lms/service/lms-api/lmsApi.wsdl"
node="/wsdl:definitions/wsdl:types/xsd:schema[
#targetNamespace='http://pk/training/basit/webservice/message/lmsapi/serviceoperations'
]/xsd:element[#name='CreateTrainingPlanRequest' or #name='CreateTrainingPlanResponse'
or #name='AssignTrainingPlanToLearnerRequest']">
i.e. change and to or.
Update:
If you're trying to select an xsd:schema element that has xsd:element children with all three names, here is the XPath expression you need:
node="/wsdl:definitions/wsdl:types/xsd:schema[
#targetNamespace='http://pk/training/basit/webservice/message/lmsapi/serviceoperations'
and xsd:element[#name='CreateTrainingPlanRequest'] and
xsd:element[#name='CreateTrainingPlanResponse'] and
xsd:element[#name='AssignTrainingPlanToLearnerRequest']"

xsd validation in CodeIgniter

I am using CodeIgniter, and I want to validate xml with below xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:simpleType name="non_empty_string">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1" />
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="xml">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="item">
<xsd:simpleType>
<xsd:union memberTypes="non_empty_string xsd:integer"/>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
when I am trying to validate xml against this xsd, only first member type is getting validated (non_empty_string ), not the second one, any guess why this is happening. Thank you.
You can use XMLReader to validate your XML against xsd file.
refer this link for more information
http://de.php.net/manual/en/xmlreader.setschema.php

JAXB2 parsing WSDL containing soap encoded type

I have a problem with jaxb2 in my spring WS.
the Spring ws has to parse a wsdl file (no xsd) containing soap encoded types (Array).What maven plugin can i use to be able to marshall the wsdl file with JAXB2?
Here is the wsdl file:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://xml.cibg.org/irisbox/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:impl="http://xml.cibg.org/irisbox/" xmlns:intf="http://xml.cibg.org/irisbox/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xml.cibg.org/irisbox/">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="soap-encoding.xsd"/>
<xsd:complexType name="ArrayOf_xsd_anyType">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:anyType[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ExternalIdsResponse">
<xsd:sequence>
<xsd:element name="externalIdsResponse" nillable="true" type="impl:ArrayOf_xsd_anyType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<message name="getExternalIdsRequest">
<part name="organizationCode" type="xsd:string"/>
<part name="externalModuleName" type="xsd:string"/>
<part name="fromDate" type="xsd:dateTime"/>
<part name="toDate" type="xsd:dateTime"/>
</message>
<message name="getExternalIdsResponse">
<part name="getExternalIdsReturn" type="impl:ExternalIdsResponse"/>
</message>
<portType name="ExternalIdsService">
<operation name="getExternalIds" parameterOrder="organizationCode externalModuleName fromDate toDate">
<input name="getExternalIdsRequest" message="impl:getExternalIdsRequest"/>
<output name="getExternalIdsResponse" message="impl:getExternalIdsResponse"/>
</operation>
</portType>
<binding name="ExternalIdsSoapBinding" type="impl:ExternalIdsService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getExternalIds">
<wsdlsoap:operation soapAction=""/>
<input name="getExternalIdsRequest">
<wsdlsoap:body use="encoded" namespace="http://xml.cibg.org/irisbox/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output name="getExternalIdsResponse">
<wsdlsoap:body use="encoded" namespace="http://xml.cibg.org/irisbox/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="ExternalIdsServiceService">
<port name="ExternalIds" binding="impl:ExternalIdsSoapBinding">
<wsdlsoap:address location="http://172.31.50.155:8988/irisbox/anonymous/services/ExternalIds"/>
</port>
</service>
</wsdl:definitions>

What is wrong with this xsd?

The following XSD should validate that the favorite_fruit element's name attribute should only contain names of fruit in the fruits element. Here is the XSD:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="Fruit">
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="FruitArray">
<xsd:sequence>
<xsd:element name="fruit" minOccurs="0" maxOccurs="unbounded" type="Fruit"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="fruit_basket">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="fruits" minOccurs="1" maxOccurs="1" type="FruitArray"/>
<xsd:element name="favourite_fruit" minOccurs="1" maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:key name="fruit_lookup">
<xsd:selector xpath="fruits/fruit"/>
<xsd:field xpath="#name"/>
</xsd:key>
<xsd:keyref name="favourite_fruit_constraint" refer="fruit_lookup">
<xsd:selector xpath="favourite_fruit"/>
<xsd:field xpath="#name"/>
</xsd:keyref>
</xsd:element>
</xsd:schema>
The following xml should be valid but when validated is invalid:
<fruit_basket>
<fruits>
<fruit name="Apple"/>
<fruit name="Peach"/>
<fruit name="Bananna"/>
</fruits>
<favourite_fruit name="Apple"/>
</fruit_basket>
Any ideas? My gut feels is that there is something wrong with my xpath. PS: I am using lxml to validate the xml against the xsd.
The anonymous complex type specifies a attribute 'name' without a type. The Fruit type has a attribute 'name' with a type of : xsd:string. Because the two attributes doesn't have the same type they can't match. Thus changing the anonymous complex type attribute definition to : works.
You have not given a type to the xsd:element of favourite_fruit. So the schema cannot validate against the type Fruit:
<xsd:element name="favourite_fruit" minOccurs="1" maxOccurs="1">
<xsd:complexType>
<xsd:attribute name="name" use="required"/>
</xsd:complexType>
</xsd:element>
Nowhere are you constraining the type to be a Fruit. This should work better:
<xsd:element name="favourite_fruit" minOccurs="1" maxOccurs="1" Type="Fruit" />

Validating XML: No matching global declaration available for the validation root

I'm trying to validate the following XML against a XSD schema using Ruby.
It simply won't work, stops with an error message telling me
Error: Element 'request': No matching global declaration available for the validation root.
Maybe it's the namespace? Any ideas?
XML
<?xml version="1.0" encoding="UTF-8"?>
<request type="test" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<channel name="channel">
<username>user</username>
<password>pass</password>
</channel>
<hotel id="1">
<date from="2009-07-07" to="2009-07-17"/>
<room id="1">
<allocation>10</allocation>
</room>
</hotel>
</request>
XSD
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- channel -->
<xsd:element name="channel">
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:sequence>
<xsd:element username="name" use="required" type="xsd:string"/>
<xsd:element password="country" use="required" type="xsd:string"/>
</xsd:sequence>
</xsd:element>
<!-- hotel -->
<xsd:element name="hotel">
<xsd:attribute name="id" use="required" type="xsd:string" />
<xsd:sequence>
<xsd:element name="hotel">
<xsd:attribute name="from" use="required" type="xsd:string" />
<xsd:attribute name="to" use="required" type="xsd:string" />
</xsd:element>
<xsd:element ref="room" minOccurs="1"/>
</xsd:sequence>
</xsd:element>
<!-- room -->
<xsd:element name="room">
<xsd:sequence>
<xsd:element name="allocation" type="xsd:string"></xsd:element>
<xsd:element ref="hotel" minOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="id" use="required" type="xsd:string" />
</xsd:element>
<!-- building all together -->
<xsd:element name="request">
<xsd:attribute name="type" use="required" type="xsd:string" />
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="channel" maxOccurs="1"/>
<xsd:element ref="hotel" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Ruby code
require "xml"
document = LibXML::XML::Document.file("/tmp/test.xml")
schema = LibXML::XML::Document.file("/tmp/request.xsd")
result = document.validate_schema(schema) do |message,flag|
log.debug(message)
puts message
end
It's a cryptic error, but it's probably because your XSD is malformed. For example, the contents of the channel, hotel (both the inner and outer elements), room, and request xsd:element tags should all be wrapped in xsd:complexType tags. Also, use is only valid on xsd:attribute, not xsd:element. For elements, use minOccurs and maxOccurs (although both default to 1, so they aren't actually necessary in this case). In addition, your outer hotel element contains a room element, which must contain a hotel element, creating an infinite loop. Further, you don't name your username and password elements properly. Finally, that inner hotel element should probably be date. Here's what I think you're looking for:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- channel -->
<xsd:element name="channel">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="username" type="xsd:string"/>
<xsd:element name="password" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<!-- hotel -->
<xsd:element name="hotel">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="date">
<xsd:complexType>
<xsd:attribute name="from" use="required" type="xsd:string" />
<xsd:attribute name="to" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element ref="room" minOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="id" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<!-- room -->
<xsd:element name="room">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="allocation" type="xsd:string"></xsd:element>
</xsd:sequence>
<xsd:attribute name="id" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<!-- building all together -->
<xsd:element name="request">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="channel" maxOccurs="1"/>
<xsd:element ref="hotel" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute name="type" use="required" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:schema>
Just shooting from the hip here, but have you tried converting the XML::Document holding the schema into an XML::Schema?
http://libxml.rubyforge.org/rdoc/classes/LibXML/XML/Schema.html
I don't know that it would make a difference, but it's worth a shot.
I received the same cryptic error message for a different reason.
The first line of my schema file had an unprefixed namespace:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sec.gov/edgar/document/thirteenf/informationtable" xmlns:ns1="http://www.sec.gov/edgar/common" targetNamespace="http://www.sec.gov/edgar/document/thirteenf/informationtable" elementFormDefault="qualified" attributeFormDefault="unqualified">
Note the 'xmlns=' attribute. This placed all the elements declared in the schema into the namespace http://www.sec.gov/edgar/document/thirteenf/informationtable (unless otherwise specified with a namespace prefix). But the XML file that I was trying to validate did not have a matching unprefixed/default namespace:
<informationTable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
So its elements didn't match the schema because they were in "different" namespaces. I hope this is useful to others.

Resources