Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends

I want to create one web service but I have many classes. I want to call all classes in single wsdl.

For example [Assume web service implemented in this class]

namespace User
{
public class MyClass1
{
    public string Name(){return "Imrankhan";}
}
}

namespace User
{
public class MyClass2
{
    public string Surname(){return "Pathan";}
}
}


my Asmx file is User.asmx.

Now when I add webservice reference in website, I want to access as following way

User.MyClass1 c1=new User.MyClass1();
string name = c1.Name();

User.MyClass2 c2=new User.MyClass2();
string surname = c2.Surname();



Is it possible? If yes, please guide me

Regard
Imrankhan
Posted
Comments
Sandeep Mewara 19-May-10 5:25am    
I think, if you would had created a test project and instead of pasting those lines here, pasting it there would had given you a reply!

As far i know you need to add '[WebMethod]' in your method in webservice.

like

[WebMethod]
public string Name(){return "Imrankhan";}



Hope this help.
 
Share this answer
 
As far as I know, you can't instantiate/return a class from a web service. A web service exposes methods, not classes.
 
Share this answer
 
No. You cannot refer to the namespace of a web service directly.

You will need to generate a proxy for your original classes (hosted on the server) and then create an instance of these proxy classes. The proxy is automatically generated for you when you 'add a service reference' to your project. You still need to instantiate these proxy classes in your code and call the appropriate web methods.
 
Share this answer
 
Test yourself. URL https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl
paypal.sandbox is reference for sandbox web service*/

You will see here this web services exposes class */

class AddressType
paypal.sandbox.AddressType addressType = new paypal.sandbox.AddressType();
       addressType.AddressID = "Your Address ID";


Another class DoDirectPaymentResponseType
paypal.sandbox.DoDirectPaymentResponseType response = new paypal.sandbox.DoDirectPaymentResponseType();
       response.TransactionID = "25554d";


How it possible that multiple classes exposes in single webservice
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900