A have description of the Web service that I need to implement.
order-processor-Service.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:port="http://xxxx.yy.ru/services/forms/integration/orderprocess"
xmlns:tns="http://xxxx.yy.ru/services/forms/integration/orderprocess"
targetNamespace="http://xxxx.yy.ru/services/forms/integration/orderprocess"
>
<wsdl:import namespace="http://xxxx.yy.ru/services/forms/integration/orderprocess" location="order-processor.wsdl"/>
<wsdl:binding name="OrderProcessorSOAP" type="port:IOrderProcessor">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="processOrder">
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="fault">
<soap:fault name="fault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OderProcessorService">
<wsdl:port name="OrderProcessorSoap" binding="tns:OrderProcessorSOAP">
<soap:address location="http://localhost/OrderProcessorService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
order-processor.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:data="http://xxxx.yy.ru/services/forms/integration/orderprocess"
xmlns:tns="http://xxxx.yy.ru/services/forms/integration/orderprocess"
targetNamespace="http://xxxx.yy.ru/services/forms/integration/orderprocess"
>
<wsdl:types>
<xs:schema>
<xs:import namespace="http://xxxx.yy.ru/services/forms/integration/orderprocess" schemaLocation="order-processor.xsd"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="processOrderRequest">
<wsdl:part name="params" element="data:processOrder" />
</wsdl:message>
<wsdl:message name="processOrderResponse">
<wsdl:part name="params" element="data:processOrderResponse" />
</wsdl:message>
<wsdl:message name="OrderProcessorException">
<wsdl:part name="params" element="data:processOrderFault" />
</wsdl:message>
<wsdl:portType name="IOrderProcessor">
<!-- wsdl:portType customizations -->
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>true</jaxws:enableWrapperStyle>
</jaxws:bindings>
<wsdl:operation name="processOrder">
<wsdl:input name="message" message="tns:processOrderRequest" />
<wsdl:output name="return" message="tns:processOrderResponse" />
<wsdl:fault name="fault" message="tns:OrderProcessorException" />
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
order-processor.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xxxx.yy.ru/services/forms/integration/orderprocess"
xmlns:tns="http://xxxx.yy.ru/services/forms/integration/orderprocess"
xmlns:types="http://xxxx.yy.ru/services/forms/integration/types"
elementFormDefault="qualified"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.0"
>
<xs:import namespace="http://xxxx.yy.ru/services/forms/integration/types" schemaLocation="forms-services-types.xsd"/>
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings>
<jaxb:javaType name="java.util.Calendar" xmlType="xs:date"
parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime"
printMethod="javax.xml.bind.DatatypeConverter.printDateTime"
/>
<jaxb:javaType name="java.util.Calendar" xmlType="xs:dateTime"
parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime"
printMethod="javax.xml.bind.DatatypeConverter.printDateTime"
/>
<jaxb:serializable uid="1" />
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
<xs:element name="processOrder" type="tns:ProcessOrderRequest" />
<xs:element name="processOrderResponse" type="tns:ProcessOrderResponse" />
<xs:element name="processOrderFault" type="xs:string">
<xs:annotation>
<xs:documentation>
Элемент содержит сообщение об ошибке (то что будет пользователю показываться)
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="ProcessOrderRequest">
<xs:sequence>
<xs:element name="OrderHeader" type="tns:OrderHeader">
<xs:annotation>
<xs:documentation>
Доступная служебная информация о заявке (почти все, что хранится в базе)
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="OrderPayload" >
<xs:annotation>
<xs:documentation>
Модель данных из формы
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:any/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="OrderAttachments" type="tns:OrderAttachments" >
<xs:annotation>
<xs:documentation>
Прикрепленные файлы из формы
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProcessOrderResponse">
<xs:sequence>
<xs:annotation>
<xs:documentation>
Идентификатор заявки назначенный внешней сиситемой
</xs:documentation>
</xs:annotation>
<xs:element name="return" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="OrderHeader">
<xs:sequence>
<xs:element ref="types:order"/>
<xs:element ref="types:service"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="OrderAttachments">
<xs:sequence>
<xs:element ref="types:attachments" />
</xs:sequence>
</xs:complexType>
</xs:schema>
and forms-services-types.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xxxx.yy.ru/services/forms/integration/types"
xmlns:tns="http://xxxx.yy.ru/services/forms/integration/types"
elementFormDefault="qualified"
>
<xs:element name="order" type="tns:OrderType"/>
<xs:element name="service" type="tns:ServiceType"/>
<xs:element name="attachments" >
<xs:complexType>
<xs:sequence>
<xs:element name="attachment" type="tns:AttachmentType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="OrderType">
<xs:sequence>
<xs:element name="guid" type="xs:string">
<xs:annotation>
<xs:documentation>
внутренний мдентификатор заявки. для служебного пользования
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="humanID" type="xs:string">
<xs:annotation>
<xs:documentation>
идентификатор заявки отображаемый пользователю
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="externalId" type="xs:string">
<xs:annotation>
<xs:documentation>
идентификатор заявки, присваеваемый обрабатывающей сиситемой.
Если система поддерживает наши идентификаторы, то вероятно будет равен guid
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="creationDate" type="xs:dateTime">
<xs:annotation>
<xs:documentation>
дата создаия заявки
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="userId" type="xs:string">
<xs:annotation>
<xs:documentation>
идентификатор пользователя, подавшего заявку
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="serviceId" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ServiceType">
<xs:sequence>
<xs:element name="guid" type="xs:string">
<xs:annotation>
<xs:documentation>
идентификатор услуги
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="name" type="xs:string">
<xs:annotation>
<xs:documentation>
имя услуги
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="orderPrefix" type="xs:string">
<xs:annotation>
<xs:documentation>
префикс для идентификтора заявки данной услуги.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="properties">
<xs:annotation>
<xs:documentation>
свойства специфичные для обработчиков данной услуги
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="property" type="tns:PropertyType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="PropertyType">
<xs:sequence>
<xs:element name="value" type="xs:string"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType name="AttachmentType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="mimeType" type="xs:string"/>
<xs:element name="data" type="xs:base64Binary"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
When I try to generate code using wsimport - all good, but when I use wsdl.exe - I get an error:
C:\Documents and Settings\Alex\Рабочий стол\orders-processing>"C:\Program Files\
Microsoft SDKs\Windows\v7.0A\bin\wsdl.exe" /serverInterface order-processor-Serv
ice.wsdl order-processor.wsdl order-processor.xsd forms-services-types.xsd
Microsoft (R) Web Services Description Language Utility
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
Error: Unable to import binding 'OrderProcessorSOAP' from namespace 'http://xxxx
.yy.ru/services/forms/integration/orderprocess'.
- Unable to import operation 'processOrder'.
- The operation binding 'processOrder' from namespace 'http://xxxx.yy.ru/servi
ces/forms/integration/orderprocess' had invalid syntax. Missing soap:operation
binding.
If you would like more help, please type "wsdl /?".
I need a service implementation for C#, not java.
Please, help me.
The error message
Missing soap:operation binding
implies that you need to use a
<soap:operation soapAction="" />
declaration or similar.
The absence of this declaration can cause the error you are experiencing.
Related
I'm trying to validate this XML file
<session>
<mic id="1" posname="T1" x="0.0" y="0.0" z="0.0" />
</session>
using this XSD file
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified"
elementFormDefault="qualified">
<xs:element name="session">
<xs:complexType>
<xs:sequence>
<xs:element name="mic" type="micType" minOccurs="1" maxOccurs="4">
</xs:element>
<xs:complexType name="micType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:int" name="id"/>
<xs:attribute type="xs:string" name="posname"/>
<xs:attribute type="xs:float" name="x"/>
<xs:attribute type="xs:float" name="y"/>
<xs:attribute type="xs:float" name="z"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
but I get this error message:
XmlSchema error: Element http://www.w3.org/2001/XMLSchema:complexType is invalid in this context.
If I just have the attribute definition for the mic element the program runs fine. I don't know what I'm doing wrong. I'm trying to have the XSD validate the data types for the mic element. Can anybody please tell me what I'm doing wrong?
The complexType named micType should be defined as a global type declaration, i.e. it should be an immediate child of the xs:schema element.
What you have is a non-viable hybrid of a local and global declaration of a complex type. Either define a micType globally (as Michael Kay mentioned) or locally:
Global complexType declaration
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified"
elementFormDefault="qualified">
<xs:element name="session">
<xs:complexType>
<xs:sequence>
<xs:element name="mic" type="micType" minOccurs="1" maxOccurs="4"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="micType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:int" name="id"/>
<xs:attribute type="xs:string" name="posname"/>
<xs:attribute type="xs:float" name="x"/>
<xs:attribute type="xs:float" name="y"/>
<xs:attribute type="xs:float" name="z"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
Local complexType declaration
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified"
elementFormDefault="qualified">
<xs:element name="session">
<xs:complexType>
<xs:sequence>
<xs:element name="mic" minOccurs="1" maxOccurs="4">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:int" name="id"/>
<xs:attribute type="xs:string" name="posname"/>
<xs:attribute type="xs:float" name="x"/>
<xs:attribute type="xs:float" name="y"/>
<xs:attribute type="xs:float" name="z"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Either way is ok and will successfully validate your XML.
I wanted to use both xs:extensions and xs:restriction together in my XSD for the below mentioned XML
<?xml version="1.0" encoding="utf-8"?>
<records>
<row id="1">
<record>
<Value class="field">486.89</Value>
</record>
<record>
<Value class="field">811.49</Value>
</record>
</row>
<row id="2">
<record>
<Value class="field">123.45</Value>
</record>
<record>
<Value class="field">678.91</Value>
</record>
</row>
</records>
Below is the XSD im trying :
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="records">
<xs:complexType>
<xs:sequence>
<xs:element name="row">
<xs:complexType>
<xs:sequence>
<xs:element name="record" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Value">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="12"/>
<xs:fractionDigits value="2" />
</xs:restriction>
</xs:simpleType>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute type="xs:string" name="class" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:byte" name="id" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The above XSD is not working ,which is the solution I found here Using xs:extension & xs:restriction together?. It's throwing an error 'complexType' element already exists in the content model.
You must globally define and name the restricted xs:simpleType that you wish to extend, not define it locally under Value.
Note also that on row you need maxOccurs="unbounded" (or something greater than the default of 1).
Altogether, this XSD will validate your XML successfully:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="Decimal12.2">
<xs:restriction base="xs:decimal">
<xs:totalDigits value="12"/>
<xs:fractionDigits value="2" />
</xs:restriction>
</xs:simpleType>
<xs:element name="records">
<xs:complexType>
<xs:sequence>
<xs:element name="row" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="record" maxOccurs="unbounded"
minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Value">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="Decimal12.2">
<xs:attribute type="xs:string"
name="class"
use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:byte" name="id" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I have the attached WSDL and i need to generate client stubs using Visual Studio 2013, WCF and .NET 4.5. Instead of the expected parameter BoolExpression in the signature, i get an object[] parameter.The generated getResourceList service method looks like this:
public TestFieldSOAP.ServiceReference1.ResourceWrapper[] getResourceList(long arg0, long arg1, object[] arg2, object[] arg3)
while it should look like this:
public TestFieldSOAP.ServiceReference1.ResourceWrapper[] getResourceList(long arg0, long arg1, BoolExpression be, object[] arg3)
In a few words, the entity BoolExpression is defined in the schema, but is not referenced as parameter in the method. I have been researching a lot on WSDLs and XSDs, but i haven't found the answer so far.
Any ideas?
The WSDL
<?xml version="1.0" ?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://ResourceManagementBasic.webservices.xxx.com/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns3="http://schemas.xmlsoap.org/soap/http"
xmlns:ns2="http://security.lowLevel.hello.webservices.xxx.com/"
xmlns:ns1="http://ResourceManagement.hello.xxx.com/" name="WSResourceAdmin_v15Service"
targetNamespace="http://ResourceManagementBasic.webservices.xxx.com/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://hello.xxx.com/" elementFormDefault="qualified"
targetNamespace="http://hello.xxx.com/" version="1.0">
<xs:complexType name="BoolExpression">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="expressions"
nillable="true" type="xs:anyType"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="AttributeOperatorValueExpression">
<xs:complexContent>
<xs:extension base="tns:BoolExpression">
<xs:sequence>
<xs:element name="attribute" nillable="true" type="xs:string"></xs:element>
<xs:element name="operator" nillable="true" type="xs:string"></xs:element>
<xs:element name="value" nillable="true" type="xs:anyType"></xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="ANDExpression">
<xs:complexContent>
<xs:extension base="tns:BoolExpression">
<xs:sequence></xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="Wrapper">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="value" nillable="true"
type="xs:anyType"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://Wrappers.hello.xxx.com" version="1.0">
<xs:complexType name="ResourceWrapper">
<xs:sequence>
<xs:element form="qualified" name="Resource" nillable="true" type="xs:long"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://ResourceManagementBasic.webservices.xxx.com/"
xmlns:ns6="http://Wrappers.hello.xxx.com" xmlns:ns1="http://hello.xxx.com/"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://ResourceManagementBasic.webservices.xxx.com/">
<xs:import namespace="http://hello.xxx.com/"></xs:import>
<xs:import namespace="http://Wrappers.hello.xxx.com"></xs:import>
<xs:element name="getResourceList" type="tns:getResourceList"></xs:element>
<xs:element name="getResourceListResponse" type="tns:getResourceListResponse"></xs:element>
<xs:complexType name="getResourceListResponse">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="return"
type="ns6:ResourceWrapper"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getResourceList">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:long"></xs:element>
<xs:element minOccurs="0" name="arg1" type="xs:long"></xs:element>
<xs:element minOccurs="0" name="arg2" type="ns1:BoolExpression" form="qualified"></xs:element>
<xs:element maxOccurs="unbounded" minOccurs="0" name="arg3" type="xs:anyType"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="getResourceListResponse">
<wsdl:part element="tns:getResourceListResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getResourceList">
<wsdl:part element="tns:getResourceList" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="WSResourceAdmin_v15">
<wsdl:operation name="getResourceList">
<wsdl:input message="tns:getResourceList" name="getResourceList">
</wsdl:input>
<wsdl:output message="tns:getResourceListResponse" name="getResourceListResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WSResourceAdmin_v15ServiceSoapBinding"
type="tns:WSResourceAdmin_v15">
<soap12:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"></soap12:binding>
<wsdl:operation name="getResourceList">
<soap12:operation soapAction="" style="document"></soap12:operation>
<wsdl:input name="getResourceList">
<soap12:body use="literal"></soap12:body>
</wsdl:input>
<wsdl:output name="getResourceListResponse">
<soap12:body use="literal"></soap12:body>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WSResourceAdmin_v15Service">
<wsdl:port binding="tns:WSResourceAdmin_v15ServiceSoapBinding"
name="WSResourceAdmin_v15Port">
<soap12:address
location="xxx"></soap12:address>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Here is also the method signature of the generated getResource method stub
[System.Xml.Serialization.XmlArrayItemAttribute("expressions", Namespace="http://hello.xxx.com/")]
public object[] arg2 {
EDIT 8th of Feb 2016
It seems like valid fixed is right: the object[] is a result of the anyType sequence defined within the BoolExpression type. I read that removing the import to the namespace of the BoolExpression will cause the svcutil generator to include the BoolExpression as a parameter in the generated method. Would this work? Or would you propose to use another workaround? I cannot test my assumption at the time since i am running from one .NET bug to the other
Its how wsdl defines it.
Elements that are type="**:anyType" are mapped to Object objects.
I am using C# 4.5/Visual Studio 2012 to try to load an XML file to a DataSet. I read the instructions here:
http://msdn.microsoft.com/en-us/library/fx29c3yd.aspx
I am loading an XML file that looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<UnitTestDataSet xmlns="https://rebuildinghomes.codeplex.com/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://rebuildinghomes.codeplex.com/ UnitTestLoadData.xsd">
<Person>
<PersonId>1111</PersonId>
<FirstName>Unit</FirstName>
<LastName>Tester</LastName>
</Person>
</UnitTestDataSet>
With a schema like this:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="RebuildingUnitTestData"
targetNamespace="https://rebuildinghomes.codeplex.com/"
xmlns:u="https://rebuildinghomes.codeplex.com/"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:complexType name="PersonType">
<xs:sequence>
<xs:element name="PersonId" type="xs:int"
minOccurs="1" maxOccurs="1" />
<xs:element name="FirstName" type="xs:string"
minOccurs="1" maxOccurs="1" />
<xs:element name="LastName" type="xs:string"
minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Using the following C# code:
//Load init/expected
DataSet init = new DataSet();
init.ReadXmlSchema("RebuildingModel/Data/UnitTestLoadData.xsd");
init.ReadXml("RebuildingModel/Data/PersonUnitTest.xml", XmlReadMode.ReadSchema);
However, when I look at "init" in the debugger, the DataSet is empty. What am I doing wrong?
Sadly, your snippet of code seem to work on my machine. Are you sure you're checking init AFTER the init.ReadXml() statement executes?
See my output from my Visual Studio immediate window below:
ds.Tables[0]
{Person}
base {System.ComponentModel.MarshalByValueComponent}: {Person}
CaseSensitive: false
ChildRelations: {System.Data.DataRelationCollection.DataTableRelationCollection}
Columns: {System.Data.DataColumnCollection}
Constraints: {System.Data.ConstraintCollection}
DataSet: {System.Data.DataSet}
DefaultView: {System.Data.DataView}
DisplayExpression: ""
ExtendedProperties: Count = 0
HasErrors: false
IsInitialized: true
Locale: {en-US}
MinimumCapacity: 50
Namespace: "https://rebuildinghomes.codeplex.com/"
ParentRelations: {System.Data.DataRelationCollection.DataTableRelationCollection}
Prefix: ""
PrimaryKey: {System.Data.DataColumn[0]}
RemotingFormat: Xml
Rows: {System.Data.DataRowCollection}
Site: null
TableName: "Person"
ds.Tables[0].Rows
{System.Data.DataRowCollection}
base {System.Data.InternalDataCollectionBase}: {System.Data.DataRowCollection}
Count: 1
My DataSet is populated with a single table containing a single row as per your XML.
I finally figured this out.
The schema now looks like this:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="UnitTestDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections />
<Tables />
<Sources />
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="UnitTestDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_DataSetName="UnitTestDataSet" msprop:Generator_UserDSName="UnitTestDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Person" msprop:Generator_TableClassName="PersonDataTable" msprop:Generator_TableVarName="tablePerson" msprop:Generator_TablePropName="Person" msprop:Generator_RowDeletingName="PersonRowDeleting" msprop:Generator_RowChangingName="PersonRowChanging" msprop:Generator_RowEvHandlerName="PersonRowChangeEventHandler" msprop:Generator_RowDeletedName="PersonRowDeleted" msprop:Generator_UserTableName="Person" msprop:Generator_RowChangedName="PersonRowChanged" msprop:Generator_RowEvArgName="PersonRowChangeEvent" msprop:Generator_RowClassName="PersonRow">
<xs:complexType>
<xs:sequence>
<xs:element name="PersonId" msprop:Generator_ColumnVarNameInTable="columnPersonId" msprop:Generator_ColumnPropNameInRow="PersonId" msprop:Generator_ColumnPropNameInTable="PersonIdColumn" msprop:Generator_UserColumnName="PersonId" type="xs:int" />
<xs:element name="FirstName" msprop:Generator_ColumnVarNameInTable="columnFirstName" msprop:Generator_ColumnPropNameInRow="FirstName" msprop:Generator_ColumnPropNameInTable="FirstNameColumn" msprop:Generator_UserColumnName="FirstName" type="xs:string" />
<xs:element name="LastName" msprop:Generator_ColumnVarNameInTable="columnLastName" msprop:Generator_ColumnPropNameInRow="LastName" msprop:Generator_ColumnPropNameInTable="LastNameColumn" msprop:Generator_UserColumnName="LastName" type="xs:string" />
<xs:element name="HomePhoneNbr" msprop:Generator_ColumnVarNameInTable="columnHomePhoneNbr" msprop:Generator_ColumnPropNameInRow="HomePhoneNbr" msprop:Generator_ColumnPropNameInTable="HomePhoneNbrColumn" msprop:Generator_UserColumnName="HomePhoneNbr" type="xs:string" minOccurs="0" />
<xs:element name="CellPhoneNbr" msprop:Generator_ColumnVarNameInTable="columnCellPhoneNbr" msprop:Generator_ColumnPropNameInRow="CellPhoneNbr" msprop:Generator_ColumnPropNameInTable="CellPhoneNbrColumn" msprop:Generator_UserColumnName="CellPhoneNbr" type="xs:string" minOccurs="0" />
<xs:element name="StreetAddress" msprop:Generator_ColumnVarNameInTable="columnStreetAddress" msprop:Generator_ColumnPropNameInRow="StreetAddress" msprop:Generator_ColumnPropNameInTable="StreetAddressColumn" msprop:Generator_UserColumnName="StreetAddress" type="xs:string" minOccurs="0" />
<xs:element name="AptNbr" msprop:Generator_ColumnVarNameInTable="columnAptNbr" msprop:Generator_ColumnPropNameInRow="AptNbr" msprop:Generator_ColumnPropNameInTable="AptNbrColumn" msprop:Generator_UserColumnName="AptNbr" type="xs:string" minOccurs="0" />
<xs:element name="City" msprop:Generator_ColumnVarNameInTable="columnCity" msprop:Generator_ColumnPropNameInRow="City" msprop:Generator_ColumnPropNameInTable="CityColumn" msprop:Generator_UserColumnName="City" type="xs:string" minOccurs="0" />
<xs:element name="County" msprop:Generator_ColumnVarNameInTable="columnCounty" msprop:Generator_ColumnPropNameInRow="County" msprop:Generator_ColumnPropNameInTable="CountyColumn" msprop:Generator_UserColumnName="County" type="xs:string" minOccurs="0" />
<xs:element name="StateProvCd" msprop:Generator_ColumnVarNameInTable="columnStateProvCd" msprop:Generator_ColumnPropNameInRow="StateProvCd" msprop:Generator_ColumnPropNameInTable="StateProvCdColumn" msprop:Generator_UserColumnName="StateProvCd" type="xs:string" minOccurs="0" />
<xs:element name="PostalCode" msprop:Generator_ColumnVarNameInTable="columnPostalCode" msprop:Generator_ColumnPropNameInRow="PostalCode" msprop:Generator_ColumnPropNameInTable="PostalCodeColumn" msprop:Generator_UserColumnName="PostalCode" type="xs:string" minOccurs="0" />
<xs:element name="CountryCode" msprop:Generator_ColumnVarNameInTable="columnCountryCode" msprop:Generator_ColumnPropNameInRow="CountryCode" msprop:Generator_ColumnPropNameInTable="CountryCodeColumn" msprop:Generator_UserColumnName="CountryCode" type="xs:string" minOccurs="0" />
<xs:element name="NumberOfYearsAtAddr" msprop:Generator_ColumnVarNameInTable="columnNumberOfYearsAtAddr" msprop:Generator_ColumnPropNameInRow="NumberOfYearsAtAddr" msprop:Generator_ColumnPropNameInTable="NumberOfYearsAtAddrColumn" msprop:Generator_UserColumnName="NumberOfYearsAtAddr" type="xs:int" minOccurs="0" />
<xs:element name="EmailAddress" msprop:Generator_ColumnVarNameInTable="columnEmailAddress" msprop:Generator_ColumnPropNameInRow="EmailAddress" msprop:Generator_ColumnPropNameInTable="EmailAddressColumn" msprop:Generator_UserColumnName="EmailAddress" type="xs:string" minOccurs="0" />
<xs:element name="GenderCode" msprop:Generator_ColumnVarNameInTable="columnGenderCode" msprop:Generator_ColumnPropNameInRow="GenderCode" msprop:Generator_ColumnPropNameInTable="GenderCodeColumn" msprop:Generator_UserColumnName="GenderCode" type="xs:string" minOccurs="0" />
<xs:element name="EthnicityCode" msprop:Generator_ColumnVarNameInTable="columnEthnicityCode" msprop:Generator_ColumnPropNameInRow="EthnicityCode" msprop:Generator_ColumnPropNameInTable="EthnicityCodeColumn" msprop:Generator_UserColumnName="EthnicityCode" type="xs:int" minOccurs="0" />
<xs:element name="BirthDate" msprop:Generator_ColumnVarNameInTable="columnBirthDate" msprop:Generator_ColumnPropNameInRow="BirthDate" msprop:Generator_ColumnPropNameInTable="BirthDateColumn" msprop:Generator_UserColumnName="BirthDate" type="xs:date" minOccurs="0" />
<xs:element name="ResidentStatus" msprop:Generator_ColumnVarNameInTable="columnResidentStatus" msprop:Generator_ColumnPropNameInRow="ResidentStatus" msprop:Generator_ColumnPropNameInTable="ResidentStatusColumn" msprop:Generator_UserColumnName="ResidentStatus" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//Person" />
<xs:field xpath="PersonId" />
</xs:unique>
</xs:element>
</xs:schema>
The big thing that changed, as you'll notice, is all of the extraneous junk that Visual Studio adds in. Apparently, .NET needs some of this to load the data properly, most notably the primary key annotation. So the moral of the story: if you're going to load a DataSet from XML, create a schema through Visual Studio or be prepared to run it through XSLT to add all this stuff, or the results will be unpredictable, at best.
Could it be the space in the following:
xsi:schemaLocation="https://rebuildinghomes.codeplex.com/ UnitTestLoadData.xsd">
from your xml file?
When I run the xsd tool to generate vb classes against:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="Security" type="SecurityType"/>
<xs:complexType name="SecurityType">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="UsernameToken" type="UsernameToken"/>
</xs:sequence>
<xs:attribute name="mustUnderstand" type="xs:string"/>
<xs:anyAttribute/>
</xs:complexType>
<xs:complexType name="UsernameToken">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Username" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="Password" type="Password"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string"/>
</xs:complexType>
<xs:complexType name="Password">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Type" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
I get the following schema validation warnings:
Type Password is not declared
Type UsernameToken is not declared
Type SecurityType is not declared
I get the following Error:
The datatype 'SecurityType' is missing
I added xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" and it worked.