Passing a Class to a Web Service

O

ohioguy

I would like to pass a class to a Web Service. I have created an xsd
file and have converted it to a class using the following command:
xsd HelloWorldSchema.xsd /c /l:cs

The class file is generated but the Service.cs file is not recognizing
the new class. I've posted the code in hopes someone will see
something I am apparently not seeing.

How can I use this class in the web services to create a method like
this:
[WebMethod]
public void AcceptSchema (foo f)


Is this even possible?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's the code of the HelloWorldSchema.xsd file:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/
2001/XMLSchema">
<xs:element name="foo" type="foo">
</xs:element>
<xs:complexType name="foo">
<xs:sequence>
<xs:element name="bar" type="xs:string" />
<xs:element name="test" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here is the code for HelloWorldSchema.cs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be
lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System.Xml.Serialization;

//
// This source code was auto-generated by xsd, Version=2.0.50727.42.
//


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://
testSchema", IsNullable=false)]
public partial class foo {

private string barField;

private string testField;

/// <remarks/>
public string bar {
get {
return this.barField;
}
set {
this.barField = value;
}
}

/// <remarks/>
public string test {
get {
return this.testField;
}
set {
this.testField = value;
}
}
}
 
S

Som Nath Shukla

Hi U have done every thing right

just do one more thing copy the HelloWorldSchema.cs in ur App_Code folder
where there is already Service.cs file exits .

Now right click on ur project and click at add existinfg item.
add the HelloWorldSchema.cs file to ur project .Now u can refer itin ur web
methid..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top