Xerces and Eclipse Disagree : no declaration found for element - xml-validation

I have an XSD and an XML file. Eclipse (version 4.7.3) validates these files with no errors or warnings (and, yes, Eclipse is validating the XML against the XSD). However, when I hand the XSD and the XML files to Xerces (with my XercesDOMParser validation set to Always), I get this error:
no declaration found for element 'g:tssConnections'
I have searched all over, and I cannot seem to find anything that is relevant. Can anyone tell me my error? Here is the XSD:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://gecoinc.com"
xmlns:geco="http://gecoinc.com"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<xs:simpleType name="ipAddrType">
<xs:annotation>
<xs:documentation>
This type is used to create tags that contain a single
IPv4 address. This type may used for both multicast
and unicast addresses.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="([0-9]*\.){3}[0-9]*"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ipPortType">
<xs:annotation>
<xs:documentation>
This type is used to create tags that contain TCP or UDP port
numbers.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedShort">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="65535"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="serverType">
<xs:annotation>
<xs:documentation>
This type is used to create variables that hold information
needed to create a server endpoint.
</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="remotePeerPort" type="geco:ipPortType" />
</xs:all>
</xs:complexType>
<xs:complexType name="clientType">
<xs:annotation>
<xs:documentation>
This type is used to create variables that hold information
needed to create a client endpoint.
</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="remotePeerIp" type="geco:ipAddrType" />
<xs:element name="remotePeerPort" type="geco:ipPortType" />
</xs:all>
</xs:complexType>
<xs:complexType name="endpointType">
<xs:annotation>
<xs:documentation>
This type is used to create variables that hold information
needed to create an endpoint. Either a client or a server may
be created.
</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:element name="serverParams" type="geco:serverType"/>
<xs:element name="clientParams" type="geco:clientType"/>
</xs:choice>
</xs:complexType>
<xs:simpleType name="transportType">
<xs:restriction base="xs:string">
<xs:enumeration value="tcp"/>
<xs:enumeration value="udp"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="connectionType">
<xs:annotation>
<xs:documentation>
This type is used to create structures that hold all of the
information that is needed for a single connection
</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="isServer" type="xs:boolean"/>
<xs:element name="endpointParams" type="geco:endpointType"/>
<xs:element name="connectionName" type="xs:string"/>
<xs:element name="transport" type="geco:transportType"/>
<xs:element
name="multicastIntfAddr"
type="geco:ipAddrType"
minOccurs="0"
maxOccurs="1"/>
</xs:all>
</xs:complexType>
<xs:complexType name="connectionListType">
<xs:annotation>
<xs:documentation>
This type is used to create a list of connections.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element
name="connection"
type="geco:connectionType"
minOccurs="1"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="tssConnections" type="geco:connectionListType" />
</xs:schema>
And here is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<g:tssConnections
xmlns:g="http://gecoinc.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://gecoinc.com oss.xsd">
<g:connection>
<g:connectionName>CM_LOAD_PRESET_OUT</g:connectionName>
<g:isServer>false</g:isServer>
<g:endpointParams>
<g:clientParams>
<g:remotePeerIp>224.5.5.5</g:remotePeerIp>
<g:remotePeerPort>11101</g:remotePeerPort>
</g:clientParams>
</g:endpointParams>
<g:transport>udp</g:transport>
<g:multicastIntfAddr>10.0.2.15</g:multicastIntfAddr>
</g:connection>
</g:tssConnections>
Thanks very much in advance!

I found the answer to this problem. It turns out that the error message coming out of Xerces was very misleading. I had to turn on several aspects of validation in the parser, as follows:
domParser->setDoNamespaces( true );
domParser->setDoSchema( true );
domParser->setHandleMultipleImports ( true );
domParser->setValidationSchemaFullChecking( true );
Once I did that, the error went away. I hope that the above can help someone.

Related

Determining SQL Query for XML Formatting

I'm building a tool for my own use that among other functions allows me to import and export tables from an SQL database into XML format. My company has a tool that does this already but only allows the import/export and not the other functions that need to be added to it. I have a copy of some of the XML files that has been output by our old tool and I'm looking to replicate the format that it outputs in. Below is that format.
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="ini_files">
<xs:complexType>
<xs:sequence>
<xs:element name="instance" type="xs:int" minOccurs="0" />
<xs:element name="file" type="xs:string" minOccurs="0" />
<xs:element name="section" type="xs:string" minOccurs="0" />
<xs:element name="key" type="xs:string" minOccurs="0" />
<xs:element name="value" type="xs:string" minOccurs="0" />
<xs:element name="last_updated" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<ini_files>
<instance>0</instance>
<file>versions.ini</file>
<section>Actual Versions</section>
<key>28.000</key>
<value>28.000</value>
<last_updated>2015-08-25T17:44:10Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>User</section>
<key>CD Key</key>
<value>86BC011090861C115020</value>
<last_updated>2016-02-17T03:32:20Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>Install</section>
<key>Serial Number</key>
<value>492679715G806LS|1570621586</value>
<last_updated>2016-02-19T00:23:40Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>User</section>
<key>Connect</key>
<value>dsconnection</value>
<last_updated>2016-02-17T03:32:20Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>dsconnection</section>
<key>IP Address</key>
<value>127.0.0.1,192.168.0.1,192.168.1.1</value>
<last_updated>2016-02-26T00:26:25Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>dsconnection</section>
<key>Port</key>
<value>8080</value>
<last_updated>2015-08-25T17:44:11Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>dsconnection</section>
<key>Company Type</key>
<value>1</value>
<last_updated>2016-02-17T03:32:08Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>dsconnection</section>
<key>Environment</key>
<value>3Ljf10vSut+g5Pcsu4qwVnjwCN4SEoL8</value>
<last_updated>2016-02-26T00:26:26Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>User</section>
<key>Address</key>
<value>TESTING--ADDRES--VALUE</value>
<last_updated>2016-02-19T00:23:57Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>User</section>
<key>Temporary Address</key>
<value>78577739280119836672551</value>
<last_updated>2016-02-17T03:32:09Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>versions.ini</file>
<section>Profile Versions</section>
<key>Last Modified</key>
<value>2016-02-22T14:22:49</value>
<last_updated>2016-02-22T21:22:49Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>dsconnection.ini</file>
<section>dsconnection</section>
<key>Last Connected</key>
<value>2016-02-25T17:26:36</value>
<last_updated>2016-02-26T00:26:36Z</last_updated>
</ini_files>
<ini_files>
<instance>0</instance>
<file>desktop.ini</file>
<section>Online</section>
<key>Last Sent Info</key>
<value>2016-02-25T01:43:09.3739698Z</value>
<last_updated>2016-02-25T01:43:09Z</last_updated>
</ini_files>
</NewDataSet>
I'm pretty inexperienced with SQL but here is the query that I found to allow me to export to XML from our table, but the format is completely off.
osql -S (local)\instancename -U sa -P P#ssW0rd-d db_name -oC:\testing.xml -Q"SELECT * from ini_files for XML AUTO, BINARY BASE64"
If I don't export in BINARY BASE64 it throws this error.
FOR XML AUTO requires primary keys to create references for 'data'.
Select primary keys, or use BINARY BASE64 to obtain binary data in
encoded form if no primary keys exist.
I tried using XML RAW as well and it throws this error.
FOR XML EXPLICIT and RAW modes currently do not support addressing
binary data as URLs in column 'data'. Remove the column, or use the
BINARY BASE64 mode, or create the URL directly using the
'dbobject/TABLE[#PK1="V1"]/#COLUMN' syntax.
I did a bit of searching but wasn't able to find anything concrete on replicating the output.
Can anyone identify what command is being used to export the XML listed above? Any help would be greatly appreciated.
Found my own answer. The format is part of .NET/C#. Here's the code I used to generate it.
string sExportTableQuery = "SELECT* from ini_files";
sSharedServer = "(local)\\instancename";
sSharedDatabase = "db_name";
sSharedUser = "sa";
sSharedPassword = "P#ssW0rd";
string sConnectionString = "Server=" + sSharedServer + ";Database=" + sSharedDatabase + ";User Id=" + sSharedUser + ";Password=" + sSharedPassword + ";";
using (SqlConnection sqlConnection = new SqlConnection(sConnectionString))
{
SqlCommand sqlCommand = new SqlCommand(sExportTableQuery, sqlConnection);
SqlDataAdapter da = new SqlDataAdapter(sqlCommand);
DataSet ds = new DataSet();
da.Fill(ds);
ds.Tables[0].WriteXml(#"C:\text.xml", XmlWriteMode.WriteSchema);
}

VB.NET Case Insensitive Web Reference enumeration Issue

I created a Web Reference (also tried Service Reference) to a WSDL that had the following node inside an xsd:
<xs:element name="filter">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element minOccurs="0" maxOccurs="unbounded" ref="condition" />
<xs:element minOccurs="0" maxOccurs="unbounded" ref="filter" />
</xs:choice>
<xs:attribute default="and" name="type">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="and" />
<xs:enumeration value="or" />
<xs:enumeration value="AND" />
<xs:enumeration value="OR" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute default="false" name="not" type="xs:boolean" />
</xs:complexType>
</xs:element>
When the client proxy class is created it produces this:
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225"), _
System.SerializableAttribute(), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn://wsc.acme.com/dm/2010/02/02")> _
Public Enum filterType
'''<remarks/>
[and]
'''<remarks/>
[or]
'''<remarks/>
[AND]
'''<remarks/>
[OR]
End Enum
This wouldn't build in a VB project because VB.NET is case insensitive. I tried deleting one set of and/or, but when the XML is created, it simply ignores the selected value. I also tried appending an X at the end of one the sets which also failed.
Is there a way to make this work? I also tried updating the XSD so it just had two values without success. The interesting thing to note is that default is set to "and" and while debugging it will set it to and, it doesn't actually produce the node attribute of it just generates .
You simply cannot have two enums with the same name. You can try setting the AllowMultiple attribute but the problem you are experiencing will still happen. My suggestion would be to remove the duplicate values in the original XSD and rebuild.

Tool or a way to create a DataSet.XSD from a Mapping C# .cs file or a NHibernate.hbm.xml file?

I need to create a DataSet.xsd file according to a NHibernate.hbm.xml file or a Class File. These are Mapping files and class files than we use to work with our DB.
You may ask me, why I do need a DataSet file, generating from a Nhibernate.hbm.xml file or a .cs file?
It's because we're using Crystal Reports, and we're using Frameworks, MVVM, INotifyPropertyChanged, NHibernate and after a lot of studying, for our case, would be better if we Convert an object while in executing time of program and use it to generate a report. If this tool exists, it will make easier, 'cause we have over 60, 70 columns per table in our DB. Since we're already with all these components working into our Project, it wouldn't make sense if we start to use sql queries to generate reports.
This tool, or 'the way to' create this DataSet file, need to read those file in these formats:
Nhibernate.hbm.xml file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="PCT.Domain" namespace="Gerdau.PCT.Kernel.Domain">
<class name="Furnace" table="Furnace" lazy="false">
<id name="Id" column="Id_Furnace" type="Int64">
<generator class="Geraes.GLib.GDomainBasis.CustomTableHiLoGenerator, GLib.GDomainBasis" />
</id>
<property name="Name" column="Name" type="String" length="50" not-null="true"/>
<property name="Code" column="Code" type="Char" not-null="true"/>
<property name="Mill" column="Mill" type="String" length="2" not-null="true"/>
<property name="DischEnabled" column="Disch_Enabled" type="Char" not-null="true"/>
<property name="DischEnabledTemp" column="Disch_Enabled_Temp" type="Char" not-null="true"/>
<property name="ChargeEnabled" column="Charge_Enabled" type="Char" not-null="true"/>
<property name="ChargeEnabledTemp" column="Charge_Enabled_Temp" type="Char" not-null="true"/>
</class>
</hibernate-mapping>
CSharp .cs File:
public class Furnace : BaseEntity
{
public virtual String Name { get; set; }
public virtual Char Code { get; set; }
public virtual String Mill { get; set; }
public virtual Char DischEnabled { get; set; }
public virtual Boolean DischEnabledConv
{
get
{
return DischEnabled.ConvertYesNoToBoolean();
}
set
{
DischEnabled = ((Boolean)value).ConvertYesNoToBoolean();
}
}
public virtual Boolean DischEnabledTempConv
{
get
{
return DischEnabledTemp.ConvertYesNoToBoolean();
}
set
{
DischEnabledTemp = ((Boolean)value).ConvertYesNoToBoolean();
}
}
public virtual Char DischEnabledTemp { get; set; }
public virtual Char ChargeEnabled { get; set; }
public virtual Boolean ChargeEnabledConv
{
get
{
return ChargeEnabled.ConvertYesNoToBoolean();
}
set
{
ChargeEnabled = ((Boolean)value).ConvertYesNoToBoolean();
}
}
public virtual Boolean ChargeEnabledTempConv
{
get
{
return ChargeEnabledTemp.ConvertYesNoToBoolean();
}
set
{
ChargeEnabledTemp = ((Boolean)value).ConvertYesNoToBoolean();
}
}
public virtual Char ChargeEnabledTemp { get; set; }
public virtual ConfiguracaoForno MillConv
{
get
{
if (Mill == ConfiguracaoForno.SM.ToString())
return ConfiguracaoForno.SM;
if (Mill == ConfiguracaoForno.PM.ToString())
return ConfiguracaoForno.PM;
else
return ConfiguracaoForno.NN;
}
}
public override String ToString()
{
return "Forno " + Code + " (" + Name + "): Laminador " + MillConv;
}
}
I know it's an very specific case, but if you can show to us at least a way, it'll be of great help.
Best regards,
Gustavo
Edit:
Found a way to do it: using XSD.EXE, a internal Tool from Visual Studio, i've extracted the mapping from my assembly:
C:\>xsd / c /l:CS -t:Furnace <MyAssembly>.dll -o:"D:\Temp"
But now, when I do this:
D:\>xsd /c schema0.xsd
Results in these errors:
D:\Temp>xsd /c schema0.xsd
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Schema validation warning: Type 'char' is not declared, or is not a simple type.
Line 21, position 5.
Schema validation warning: Type 'http://microsoft.com/wsdl/types/:char' is not declared. Line 10, position 7.
Schema validation warning: Type 'http://microsoft.com/wsdl/types/:char' is not declared. Line 12, position 7.
Schema validation warning: Type 'http://microsoft.com/wsdl/types/:char' is not declared. Line 15, position 7.
Schema validation warning: Type 'http://microsoft.com/wsdl/types/:char' is not declared. Line 16, position 7.
Schema validation warning: Type 'http://microsoft.com/wsdl/types/:char' is not declared. Line 19, position 7.
Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.
Error: Error generating classes for schema 'schema0'.
- The datatype 'char' is missing.
If you would like more help, please type "xsd /?".
Here's my generated schema.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://microsoft.com/wsdl/types/" />
<xs:element name="Furnace" nillable="true" type="Furnace" />
<xs:complexType name="Furnace">
<xs:complexContent mixed="false">
<xs:extension base="BaseEntity">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Name" type="xs:string" />
<xs:element minOccurs="1" maxOccurs="1" name="Code" xmlns:q1="http://microsoft.com/wsdl/types/" type="q1:char" />
<xs:element minOccurs="0" maxOccurs="1" name="Mill" type="xs:string" />
<xs:element minOccurs="1" maxOccurs="1" name="DischEnabled" xmlns:q2="http://microsoft.com/wsdl/types/" type="q2:char" />
<xs:element minOccurs="1" maxOccurs="1" name="DischEnabledConv" type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="DischEnabledTempConv" type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="DischEnabledTemp" xmlns:q3="http://microsoft.com/wsdl/types/" type="q3:char" />
<xs:element minOccurs="1" maxOccurs="1" name="ChargeEnabled" xmlns:q4="http://microsoft.com/wsdl/types/" type="q4:char" />
<xs:element minOccurs="1" maxOccurs="1" name="ChargeEnabledConv" type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="ChargeEnabledTempConv" type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="ChargeEnabledTemp" xmlns:q5="http://microsoft.com/wsdl/types/" type="q5:char" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="BaseEntity">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="Id" type="xs:long" />
</xs:sequence>
</xs:complexType>
</xs:schema>
I appreciate for any help.
Gustavo
You're missing an XSD file.
UPDATE: Let's assume you're staying with xsd.exe. In this case, modify the import statement as following (I call this file XSD-1.xsd):
<xs:import namespace="http://microsoft.com/wsdl/types/" schemaLocation="XSD-2.xsd" />
Copy the content below in XSD-2.xsd file, in the same folder:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://microsoft.com/wsdl/types/" elementFormDefault="qualified" targetNamespace="http://microsoft.com/wsdl/types/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="char">
<xs:restriction base="xs:unsignedShort" />
</xs:simpleType>
</xs:schema>
Run the xsd.exe with the following line:
xsd XSD-1.xsd /c
You should get an XSD-1.cs file and some warnings
If you want to use svcutil, you must have the XSD-2.xsd, otherwise it won't work; also, on the plus side you don't have to modify the XSD-1.xsd:
svcutil XSD-1.xsd XSD-2.xsd /dconly
It works fine, without any errors. I am running v4.

generate wcf server code from wsdl files

Greetings, I would like to generate some contract based on wsdl file. I used svcutil but I suspect it generated it wrong as all contract methods have void returned type. Is there any tool for this purpose?
EDIT:
here is the wsdl file:
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://dantek.com.pl/EDItEUR/EDItX/LibraryBookSupply/WebService/CustomerService/20100611/ServiceContract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" targetNamespace="http://mytargetNamespace/ServiceContract" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="http://mytargetNamespace/ServiceContract/Imports">
<xsd:import namespace="http http://mytargetNamespace/ServiceContract/ServiceContract" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="CustomerService_ProcessMethod_InputMessage">
<wsdl:part name="parameters" element="tns:ProcessMethod" />
</wsdl:message>
<wsdl:message name="CustomerService_ProcessMethod_OutputMessage">
<wsdl:part name="parameters" element="tns:ProcessMethodResponse" />
</wsdl:message>
>
<wsdl:portType name="CustomerService">
<wsdl:operation name="ProcessShipNotice">
<wsdl:input wsaw:Action=" http://mytargetNamespace/ServiceContract/ProcessMethod" message="tns:CustomerService_ProcessMethod_InputMessage" />
<wsdl:output wsaw:Action=" http://mytargetNamespace/ServiceContract/ProcessMethod" message="tns:CustomerService_ProcessMethod_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
And the contract created
[ServiceContract]
public interface CustomerService
{
[System.ServiceModel.OperationContractAttribute(Action = "http://mytargetNamespace/ServiceContract/CustomerService/ProcessMethod”, ReplyAction = " http://mytargetNamespace/ServiceContract/CustomerService/ProcessMethodResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute()]
void ProcessMethod(ProcessMethodRequest request);
I don't want to have ProcessMethod returned type void but rather ProcessMethodResponse type. How can I achieve it?
EDIT2: Here's my schema:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://myTargetNamespece/ServiceContract" elementFormDefault="qualified"
targetNamespace="http://myTargetNamespace/ServiceContract" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="ProcessMethod">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="request" type="tns:ProcessMethodRequest" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="ProcessMethodRequest" abstract="true" />
<xs:complexType name="ProcessMethodRequestWithPayload"/>
<xs:element name="ProcessMethodResponse">
<xs:complexType />
</xs:element>
</xs:schema>
Generated operation contract is correct. You WSDL specifies request/response operation (= two-way) with empty response. ProcessMethodResponse element is wrapper element for the response message but it does not contain any subelements = void response.
If you want to return ProcessMethodResponse you have to use message contracts. You can instruct svcutil to use message contracts by /mc or /messageContract switch.

SOAP Message contains an extra tag after generation from WSCF Blue in Visual Studio 2008

I'm using Visual Studio 2008 to write a simple web-service but have been running into some problems. You might need to format my
The full expected message is something along the lines of:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace = "http://www.website.com/WS/"
elementFormDefault = "qualified"
xmlns = "http://www.website.com/WS/"
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
>
<xs:element name="QUERYFOOTBALL">
<xs:complexType>
<xs:sequence>
<xs:element name="KEY" minOccurs="1" maxOccurs="1" type="xs:string" />
<xs:element name="FOOTBALL">
<xs:complexType>
<xs:sequence>
<xs:element name="HEADER" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="TEAM_ID" minOccurs="1" maxOccurs="1" type="xs:string" />
<xs:element name="MATCH_ID" minOccurs="1" maxOccurs="1" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GAME" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="ONE" minOccurs="1" maxOccurs="1" type="xs:string" />
<xs:element name="TWO" minOccurs="1" maxOccurs="1" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
However when I generate the service the SOAP message layout/call appears like so
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<QueryFootball xmlns="http://www.website.com/WS/">
<QUERYFOOTBALL>
<KEY>string</KEY>
<FOOTBALL>
<HEADER>
<TEAM_ID>string</TEAM_ID>
<MATCH_ID>string</MATCH_ID>
</HEADER>
<GAME>
<ONE>string</ONE>
<TWO>string</TWO>
</GAME>
</FOOTBALL>
</QUERYFOOTBALL>
</QueryFootball>
</soap:Body>
</soap:Envelope>
My actual C# code looks like this:
namespace FootballSimulator
{
[System.ServiceModel.ServiceBehaviorAttribute(InstanceContextMode=System.ServiceModel.InstanceContextMode.PerCall, ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Single)]
public class FootballSimulator : IFootballSimulator
{
public virtual QUERYFOOTBALLRESPONSE QUERYFOOTBALL(QUERYFOOTBALL request)
{
throw new System.NotImplementedException();
}
}
}
I guess my question is how can I edit the Schema/WSCFBlue so that it doesn't force that extra in the SOAP request?
I would really appreciated any advice/guidance you could give. I can give you an outline to what I did:
In visual studio I right clicked my 2 schemas (request and response message) and selected WSCFblue then Create WSDL Interface Description
I selected the correct schemas/ports and gave them message in a name of QUERYFOOTBALL and the message out a name of QUERYFOOTBALLRESPONSE
I right clicked the WSDL that was generated in above steps and went selected WSCFblue then Generate Data Contract Code (which is does and gives me my objects QUERYFOOTBALL and QUERYFOOTBALLRESPONSE)
I right clicked the WSDL and selected WSCFblue then Generate Web Service Code
If there is anything obvious that I am doing wrong I would really appreciated it if you can show me what it is. It looks asthough the method name is the causing the additional tag to be added around the expected soap message. In my schema after QUERYFOOTBALL element is another element called KEY, this is the reason I cannot just take out QUERYFOOTBALL and create an object called "FOOTBALL".
What I want the web-service to accept is this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<QUERYFOOTBALL>
<KEY>string</KEY>
<FOOTBALL>
<HEADER>
<TEAM_ID>string</TEAM_ID>
<MATCH_ID>string</MATCH_ID>
</HEADER>
<GAME>
<ONE>string</ONE>
<TWO>string</TWO>
</GAME>
</FOOTBALL>
</QUERYFOOTBALL>
</soap:Body>
</soap:Envelope>
Really appreciate any help you can give, look forward to hearing your experiences/opinions/advice
Better late than never....
Try adding this to your Web Method:
[SoapDocumentMethod(ParameterStyle = SoapParameterStyle.Bare)]