.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Sharon Maxwell
Post New Web Links

Add a class to a Web Service

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net
 

Hi all 

I have a problem i cannot solve. I searched everywhere the web but nothing.

 

How can i expose a user defined type(class) in the web service definition?. Im not refering as a parameter in a web method, what i want to do is expose the type itself so any client that consumes it have the type definition and can instanciate it.

Please, any example code!

This is what i want to achieve consuming the reference in the client

VB

dim oReference as new WSReference.UserType
oReference.name = "Charles"
oReference.adress = "Main St."

CS

WSReference.type oReference = new WSReference.UserType();
oReference.name = "Charles"
oReference.adress = "Main St."

 

 Please help i need to solve this as fast as i can!!!

 

Best regards,
Carlos Reyes.

 

 




View Complete Post


More Related Resource Links

Web Service and Base Class Sub Routines

  

Hello,

I have several Web Services that I call using jQuery, they are all <WebMethod()> _    Public Function and return either a boolean or string, depending on the function.

I have some Web Service functions, where I would like to call sub routines I have in my base class, they are Public Sub's.

When I add a call of a sub routine in the Web Service function, I get a blue line that says 'Object reference not set to an instance of an object'.  If I change the sub routine to Public Shared Sub, then the blue line and error go away, but I get other errors from the calls I was successfully making to the base class routines before.

Is there a way to get these two to work together?



How to update row using Domain Service Class programmatically?

  
How to update row using Domain Service Class programmatically in Silverlight without bind to any datagrid and other control? Please help.chanmm

How to update row using Domain Service Class programmatically?

  
How to update row using Domain Service Class programmatically in silverlight without binding to any datagrid and so? Please help.  chanmm

All data in class properties disappear across WCF service

  
Hi, I have a class that i share betwee silverlight client and wcf service. I populate properties of the class with real data from the client, to be used in the server. I use debugger to step through the code when the call gets to the server, all the data ara gone and are replaced with null. All DateTime value change to 1/1/1001. But if pass primitive types such as int, string, no problem. This is happening only on one machine, but not on ther machine. Can someone tell me what is going on here? Thanks in advance

Single class with service and callback contract

  
Can a single class implement service and callback contract. Thanks-= JL =-

Class project in Web Service-consuming website

  
I have a website project in VC2008. I add a web reference to a web service, and give it a name (ws). I can now do this:         ws.Service testService = new ws.Service();         ws.Customer objCustomer = testService.GetCustomer("1");   Perfect. Now, is it possible to move the Web Reference into a class file, referenced by my web project? I've done that, but now I can't access the ws object from the website application. Is this even possible? I've seen it done in another project, which I've tried to mimic exactly, but it's not working for me. Could it be an older version worked like that??   Thanks Sean

New public class in namespace (web service, asmx)

  

 Hi,

I have a working web service written in C#.NET that was set up by my predecessor, and have been able to successfully modify it in the past. It works without problems in production.

Basically, the service takes XML code and sends it to a postURL with an outside vendor API. They send back an XML document that we then parse out.

My issue is that I need to connect to another vendor API concurrently with the existing one.

Method 1) Should I create an entirely new Web Service for the new vendor? I tried this but there seemed to be an issue with the ports, having them run at the same time. Should I try again? Any port secrets?

Getting stuck on Method 1, I'm on to Method 2 now....

Method 2) Modifying the exiting web service by adding a new public class to the namespace. I also modified the wsdl, disco and discomap files for the new service. It did compile, but something is missing.

Service1 = exisiting, working web service

https://servername/Service1.asmx - works beautifully and lists all my API calls

https://servername/Service1.aspm?wsdl - shows my wsdl file

Service2 = new, copied web service

Add Service Reference changing list to arrays in proxy class

  

I'm trying to consume an asmx service in a console app. When I add the service reference to my project i'm noticing that in the proxy class the lists are replaced with arrays. Also, the default constructors are missing. This is causing problems when i'm attempting to build the request object using the proxy classes. I've generated some classes using xsdobjectgen which i'm using as parameters to my web method. I've tried changing the Collection type in the settings but its still not working. Any ideas on whats going wrong?

 


SSRS 2008 Web Service Datasource doesn't return embedded class

  

Hello,

I am building reports with SSRS 2008 using web services as datasource.

Let me explain my design:

I have 2 classes:

public class Employee

{ public string fname;

public string lnamel;

public Department dept;

}

public class Department

{public string name;

}

i have this function as a web method:

public Employee GetEmployee(string lastname)

{
      Employee emp = new Employee();
      // I query the DB and return the result in a datatable
     // I then bind the table fields to my Employee object
     return emp;

}

When I test the service, it return the employee's info and his/her dept info as well.

But when i test the dataset in the report, it only return the employee's info and not the department info.

Any suggestion?

Thanks a lot!!!



Add Service Reference changing list to arrays in proxy class

  

I'm trying to consume an asmx service in a console app. When I add the service reference to my project i'm noticing that in the proxy class the lists are replaced with arrays. Also, the default constructors are missing. This is causing problems when i'm attempting to build the request object using the proxy classes. I've generated some classes using xsdobjectgen which i'm using as parameters to my web method. I've tried changing the Collection type in the settings but its still not working. Any ideas on whats going wrong?

 


Web Service to inherit from a Custom Base Class that inherits System.Web.Services.WebMethod instead

  

Hi All,

Recently, I tried to get my Web Service class to inherit from a custom base class that inherits from System.Web.Services.WebMethod instead of the System.Web.Services.WebMethod directly.

However, I've been getting Error 500.

Public Class Service1
    Inherits BaseClass
    <System.Web.Services.WebMethod()> _
    Public Function GetSessionID() As String
        GetSessionID = Me.Session.SessionID
    End Function
End Class

 

public class BaseClass
    Inherits System.Web.Services.WebService

    public property Property1 as string
    public property Property2 as string

End Class

 

Please kindly assist.

Thank you in advance.

Warmest Regards,

leroylll



Is it possible to save a value to a service class from an IDispatchMessageInspector Class?

  

Fairly new to WCF.  I have a service that has a Service Behavior on it that adds a class(MessageLoggerInspector) that implements the IDispatchMessageInpector interface.  In MessageLoggerInspector, I save off the raw request and response for the service to a SQL table.  I return a unique link for that record in the table for both request and response.  I have a private property that holds both these values and when the response is saved off, it saves a link to the request and the request record is updated with a link to the response.   All this works perfectly.

I am wondering if there is some way to actually expose those links to the service itself so that I could use the link references in the service.  I've looked at the System.ServiceModel.IClientChannel and System.ServiceModel.InstanceContext objects that are passed into the AfterReceiveRequest method, but I don't see anything linking to the service as the objects seem to be more communication oriented.


Generic list of custom class returns data in WCF service layer, but loses them in Presentation Layer

  

I'm reading this excellent article by John Papa in MSDN Data Points - http://msdn.microsoft.com/en-us/magazine/cc700340.aspx

This single article alone sheds great deal of light on EF, WCF, WPF, MVP architecture, Layered Architecture with these technologies and so much more.

I'm trying to experiment with the code that comes with the article as is.

When executing the application, the service layer returns a Generic List with three Customer objects to the presentation layer. However, in presentation layer, the Generic list arrives with zero objects in the list. In the context of this application, I provide 'd' as a search criteria and hit the search button; while stepping through, I can see it returns 3 rows from the database.

With my limited experience in WCF, I am unable to figure out why it is so. This article was written  for 3.5 SP1 Beta 1. Could something changed in the general release that is causing this?


-Perennial Newbie-

Service returning Object fails when object is complex class

  

Hi. I have created a WPF client and a self-hosted WCF Service based on an interface, in wich alle methods returns a standard response class. An example of one such method definition is:

Response CreateAccount(AccountCreationParams accountParams);

 

The response object is defined as:

 

[DataContract]

public class Response

{

[DataMember]

public string ResponseText;

[DataMember]

public bool CompletedSuccesfully;

[DataMember]

public

How to visist the method or member of service class?

  

i have a service interface such as IPublishService(PublishService), and i run the service like below:

Uri publishAddress = new Uri("net.tcp://localhost:8004/QTAServer");
publishHost = new ServiceHost(typeof(PublishService), publishAddress);

suppose the pulishservice has a public member news, how can i visit the news memeber in the server client, i have tried method like below:

PublishService ps = publishHost.SingletonInstance as PublishService;

MessageBox.Show(ps.news);

but it is wrong, why is my method not correct?  is there any other method?


Adding IServiceClient interface to generated proxy service client class

  
Hi,
would it be possible to add a service client interface to a generated service client class in a generated service proxy in order to achieve easier testability?
Here's an example of what I am asking the way I do it manually http://blog.vuscode.com/malovicn/archive/2009/11/01/design-for-testability-wcf-proxies.aspx

This would not break backward compatibility (safe to be added)

Is this question more for Connect? :)

Thanks,
Nikola

Windows Service Applications Tutorials

  
You can easily create services by creating an application that is installed as a service. For example, suppose you want to monitor performance counter data and react to threshold values. You could write a Windows Service application that listens to the performance counter data, deploy the application, and begin collecting and analyzing data.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend