470,612 Members | 2,206 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,612 developers. It's quick & easy.

I'm going crazy with web services - PLEASE HELP!!

I've been days with that. I'm trying to work with web services sending and
returning objects, and the web service must store some objects.
- My first try (the most obvious in my opinion) was to use a class contained
in a extern dll so the web service and the application can use it and send
or return via web services: public customObject myWebMethod(customObject
obj); . I saw that web services can't deal with this cause the WS creates
another class with the same name, but it's not possible to cast from one to

- Now I try to pass simple fields (strings for instance) and create the
objects in the web service and in the application. In the web service I have
a Hashtable where I want the objects to be stored. Is it possible? because I
get exceptions and I don't know why. The exception text is (it's translated
as my VS isn't in english):
'System.Web.Services.Protocols.SoapException' occurred in

Additional information: System.Web.Services.Protocols.SoapException: The
server didn't recognize the value in the header HTTP SOAPAction:
System.Web.Services.Protocols.Soap11ServerProtocol Helper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.I nitialize()
at System.Web.Services.Protocols.ServerProtocolFactor y.Create(Type type,
HttpContext context, HttpRequest request, HttpResponse response, Boolean&

I have a basic test that doesn't work, but I put you here the code so you
can see if it's something wrong.

-------- The DLL has this simple class:

public class User
private string name;
private string phone;

public string Name
set { name = Name;}
get { return name;}
// the same with Phone

public User() {}
public User(string n, string p)
name = n;
phone = p;

---------- The Web Service has this:

public class Service1:System.Web.Services.WebService
private System.Collections.Hashtable users; //here I want to store
the objects

public Service1()
users = new Hashtable();

// then the region generated by VS
// and here the web mehtods

public void setUser(string n, string p)
User u = new User(n,p);
users.Add(n,u); //add the new user to the HastTable with the name
as key

public string getPhone(string name)
User u = (User)users[name]; //get the object with the key
return u.Phone;


--------- And finally the application, that is a simple form that has a
couple of textboxes to insert name and phone, a listbox to show the results
and a couple of buttons to call the web methods. I put the important code

public class Form1: System.Windows.Forms.Form
// the visual components
private webServ.Service1 serv; //the web service
private User user; //a custom object from my class.

public Form1()
serv = new webServ.Service1(); // call the web service

private void button1_Click(...)
// call the webmethod sendint the fields so the object is created in
the web service
serv.setUser(textBox1.Text, textBox2.Text);

private void button2_Click(...)
// call the second webmethod to get the Phone associated to the name
showed in the textBox
string phone = serv.getPhone(this.textBox1.Text);
User u = new User(textBox1.Text, phone); //create an object

//finally show the data in the listbox[...]

When the application crashes, it shows in the Reference.cs that:

public void setUser(string name, string phone){
this.Invoke("setUser", new object[] { name, phone});

Please, I really need your help!


Diego F.

Nov 16 '05 #1
0 1951

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Richard | last post: by
3 posts views Thread by Larry Tate | last post: by
7 posts views Thread by Miguel Dias Moura | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.