How to use Struct in Web Services using VS2005

Hi All,

I am developing a web service which recieves the information from the client application and will store those on the SQL Server database.

For this purpose, I would like to use C#.Net "struct". This is not visible from the client application.

My question is how to make this struct as visible for client application.

Please Help me.


public class Service : System.Web.Services.WebService


public Service () {


public string sampleMethod() {return "Sample Text";


public struct testStruct


public string strOne;public string strTwo;



Help is appreciated.


6/25/2008 11:41:13 AM 7071 articles. 0 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 55

WSDL will automatically create the client-side definition of the struct (but really a class) when you add a web reference to the web service, provided that struct is a parameter for a web method in the service.

Mark replies as answers if they helped you solve the problem.
6/25/2008 12:51:47 PM

sorry i dont understand ur reply. pls can you explain with some example codes.

sample code will be helpful.

thanks in advance.


6/25/2008 1:25:47 PM
Assuming you have your web method as sampleMethod(struct testStruct), when the client application adds a reference to your web service endpoint (.asmx) from VS, a proxy class resembling your struct (testStruct) will be created. Once done, the client app can start using it as if you shared the defintion of the strcut. The only thing to note is that VS will create a class, not a struct on the client-side.

Mark replies as answers if they helped you solve the problem.
6/25/2008 2:38:45 PM

Thanks for your explanation.

I put my method as you told. but i am getting error.

Error 1 Inconsistent accessibility: parameter type 'sample' is less accessible than method 'FirstService.HelloWorld(sample)'

My Code is:

1    [WebService(Namespace = "")]
2    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
4    public class FirstService : System.Web.Services.WebService
5    {
6        public FirstService()
7        {
8            //Uncomment the following line if using designed components
9            //InitializeComponent();

10       }
12       [WebMethod]
13       public string HelloWorld(sample mySample)
14       {
15           return mySample.myText;
16       }
17   }
19   struct sample
20   {
21       public string myText;
22   }

i got this error on the line number 13. pls help me.

6/26/2008 4:37:09 AM

I changed the struct as Public and got working in my client application.

Thanks for your solution.


6/26/2008 4:55:31 AM

Try this...

public class Service : System.Web.Services.WebService


public Service () {


public string sampleMethod() {return "Sample Text";



public struct testStruct


public string strOne;public string strTwo;



7/17/2008 7:32:21 AM

Similar Artilces:

Changing URL in web.config for web service
I added a web reference to asmx file. In web.config - it adds - undefinedadd key="CoreService.CoreServices" value="http://test/CoreServices.asmx I then change it to <add key="CoreService.CoreServices" value="http://test2/CoreServices.asmx"/> But CoreService.CoreServices still looks for http://test/CoreServices.asmx.  What else do i have to change? I think CoreService.CoreServices are hard coded into the source code.  Girijesh I think CoreService.CoreServices are hard coded into the source code.  Girijesh So no ...

Need help with deciding to use or not to use web services in a web application
Hi all, I haven't used web services at all in my web application development and now I was asked to use web services in my web application.  I was a novice in ASP.NET since I'm just changed to ASP.NET from a Java background. I used the tutorial on MSDN to create the DAL (which is a .xsd file type) and the BLL layers and it works pretty well for what the web application suppose to be but since I was asked to add a web service layer to this, I wonder how to do it?  And I wonder if it is necessary to have an additional layer?  What is the pros and cons for adding the we...

send data from web service to local computer, using web services.
hii have a web application, on web server , and a database on my local computer in my office.i want to send data from my web pages to my local database.i think one way is using web services.i used that, but it has permission errors.that web service have this error :  Server Error in '/in' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30180: Keyword does not name a type.Source Err...

xml web service --uploading the file to the xml web service
how can we upload the file in the xml web service 1.i mean what will be the return value in the proxy class 2.and how am i going to send the file to the xml web service----regards Bipul Kumar Here are some links to articles that helped us get this done: Hope this helps....

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

change a web reference to a web service in the config file of an object used by a windows service
In my solution (visual studios 2005), I have a windows service and a business object.  The business object has a web reference to a web service.  I maid the web reference dynamic and it created an applicationSettings section in the appconfig:<configuration>           <applicationSettings>        <Objects.Properties.Settings>            <setting name="Objects_LookupService_auth"        &nbs...

Missing Design Tab in using Web Matrix for XML Web Services
Did anyone come across the following situation? After selecting the XML Web Service template with VB.NET as the language, Sample as the class and MatrixDemo as the namespace, a code view was opened by Web Matrix. However, unlike the usually interface, I can't find any tabs underneath the code view. No design tab, no HTML tab and no ALL tab. Did I miss anything?...

Consuming a .NET web service in Delphi 2010 using a service reference
Hi, I've been asked to modify one of my existing applications (D2010 Win32) to interact with a web service written under VS2010/.Net 4. The information I have so far is :- "As communication is secured by .NET WsHttpBinding data encrypting, In order to consume it you have to add to your application a Service Reference (not a web reference) that joins the service available at the URL: . Assuming that the binding created in your app.confing is named "WSHttpBinding_ISms" you have to instantiate a client as shown below: {c...

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

'web service call failed: 500' using ajax hovermenu and web service
Hi there, I'm using a hovermenuextender attached to a templatefield of a gridview, and everything seemed to work fine.. however I've moved on to add dynamic attributes to the hovermenu. Now I get the error "web service call failed: 500" in place of the output I want (on the hovermenu's panel). When accessing the web service I created (directly through the browser) everything works fine.. here's my hovermenuextender dynamic attributes DynamicContextKey='<%=eval("refnumber") %>' DynamicServiceMethod="GetS...

Has anyone successfully used a Delphi web service client against an ENCRYPTED WCF web service server?
Has anyone successfully used a Delphi web service client against an ENCRYPTED WCF web service server? Which is to say, of course, that the URL would be starting with https. Anyone? ...

Problem calling Web Service using the DynamicPopulate Extender
Hi, I'm quite new to ASP.Net AJAX so please forgive my ignorance.  I have downloaded and installed the RC1 version and am following through some of the tutorial videos.  I am having a problem with the Dynamic Populate Extender example.  I have created some asp controls with onclick events calling a javascript function.  From there I am attempting to use a dynamic populate extender control to call a web service - it's a function declared on that ASPX page as the tutorial explains in necessary and decorated with the System.Web.Services.WebMEthod AND System.Web.Script.Serv...

web service call failed: 500 using ajax hovermenu and web service with ascx file
I am using a hovermenu extender on an image button. The hovemenu extender calls a web service and returns back information that I write to the panel that displays. A portion of the code is below. This works when the Page is an aspx page but when I move it to an ascx page I get web service call failed. I do have the ascx page in a folder called controls/pages off of the root but both the default.aspx page and the bedinfo.asmx page are on the root. I don't think I have a path problem. I can include more complete code, there are actually 50 images with 50 hovermenu extenders and one p...

Re: Using XML Web Service in VS.NET
Dear all, I added a "test.asmx" file in my current project and I coded all Web Method in the test.asmx.cs in VS.NET. Now I want to ask how can I call the web methods in other C# Class? Suppose the class name of the asmx is "test". How can I instantiate the object of that class? Regards, Joe someone can correct me on this.... i hav done a walkthrough using XML webservice. I have created a windows application that can call methods from the webservice, with the use of a dataset in the webservice. after "adding a web reference" to my windows appli...

Web resources about - How to use Struct in Web Services using VS2005 -

Public Broadcasting Service - Wikipedia, the free encyclopedia
... such as PBS NewsHour , Masterpiece , and Frontline . Since the mid-2000s, Roper polls commissioned by PBS have consistently placed the service ...

U.S. Mail Service Goes Postal Over Pot
We can add the U.S. Postal Service to the list of federal agencies that have zero clue about how to handle state-legal cannabis.

Vevo Buys Showyou Video Site in Step Toward Subscription Service
Vevo, the largest online music video service in the U.S., has acquired video streaming company Showyou, the latest sign that Vevo plans to offer ...

Judge sets 71-month sentence for former Secret Service agent who plundered Silk Road
SAN FRANCISCO—Former Secret Service agent Shaun Bridges was sentenced Monday to 71 months in prison after he stole money from Silk Road dealers ...

GM transforms soldiers into service techs
Auto dealer service and fixed operations issues.

USPS Testing Service That Shows Customers Photos Of Their Mail
... take a peek at your mailbox from afar. Because many people can’t stay home and wait for the mail to arrive, the United States Postal Service ...

TSMC applies for 12-inch wafer fab and design service center in China
... Taiwan's Ministry of Economic Affairs for an investment project to build a wholly-owned 12-inch wafer manufacturing facility and a design service ...

AT&T expands its fiber internet service to 38 new cities
... mission to blanket most of the US with gigabit internet is moving at full speed. Today, the network revealed that its GigaPower fiber service ...

Bootrash Uses Volume Boot Record to Exploit Financial Services
FireEye reports that FIN1 financial services hackers are making use of bootkit malware to infect organizations.

Apple And John Lewis Lead Retail Rankings For Value Added Services, BookingBug Study Shows
Apple and John Lewis are the top retailers for offering value added services in the US and UK respectively in 2015, according to a new Retail ...

Resources last updated: 12/8/2015 12:23:20 AM