Link to home
Start Free TrialLog in
Avatar of tocleora
tocleora

asked on

VB.Net and Soap for Noobs

I see a lot of topics on this site about Soap and VB.Net but for some reason they are all going over my head. I don't really understand all the specifics about it, I just need to call a wsdl file with some variables and get a response back.  IN PHP it's this simple:

$client = new SoapClient ('path to wsdl');

$res = client->command(array('key' => 'value'));

(where command is a command supported by the wsdl) and then I work with the results returned to res.  I have this working in PHP great but I'd rather do it in VB.  I don't know any of the xml calls being made to set headers and all of that stuff (most of the topics and articles I've read discuss setting xml manually, think this is where I'm getting lost), this is the extent of my knowledge of what to do.  Can someone point me to a topic here or a resource somewhere else that breaks it down (or if you can explain it to me that's obviously acceptable as well) in an easy to understand way? Appreciate it!
Avatar of kaufmed
kaufmed
Flag of United States of America image

Use the "Add Service Reference" option (Project->Add Service Reference...) and point it to the location of your WSDL file in the Address bar--then click "Go". You should see a list of available methods defined within the WSDL; you can also change the resulting namespace if you like in the "Namespace" bar. If the reference can be successfully added, then you will get a proxy class with which you can interact with your web service. You will use that class and its methods to pass and receive data from the web service. Be sure to make note of the namespace as it originally was or whatever you changed it to as you will need this to find the class.

Once you do all this, interacting with the service becomes a matter of creating an instance of a class and calling its methos--something you should already know how to do  = )
Avatar of tocleora
tocleora

ASKER

No, unfortunately I'm self taught and not always familiar with the lingo.  The information you gave me did work, but I'm not sure how to actually call it now.  The wsdl is on localhost, and there's a reference for that, so I can now type in:

localhost.[command]

and see results for it, but they have eventArgs and eventHandler after them.  I'm guessing these are classes but I don't have a lot of experience with classes (It's actually been a while since I've done any extensive vb programming, most in vb6).  Could you give me an example of how to call that command and get the results from it?  Then I think I'm good to go! Thanks a lot!
What did you call the Namespace (or did you leave it as the default)?
Hmmm that could be part of what I did wrong.  I've now done that part and I have a namespace called ServiceReference1.  I can now pull up ServiceReference1.[command]Request.  But not sure what to do with it.  does that answer your question or am I too confused at this point?
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hmmm that didn't work for me. If I put:

ServiceReference1.AgentBridgeClient c = new ServiceReference1.AgentBridgeClient();

It changes it to:

ServiceReference1.AgentBridgeClient(c = new ServiceReference1.AgentBridgeClient())

so I tried:

c = ServiceReference1.AgentBridgeClient()

and that didn't give me any errors.

Ok so here is the actual PHP code I'm using:

 
$client = new SoapClient('http://localhost:8080/AgentBridge?wsdl', array(
												'cache_wsdl'	=> WSDL_CACHE_NONE,
												'trace'			=> true));

$res = $client->addListener(array('name' => 'ID13'));

Open in new window


So when I do the next step:

string result = c.addListener('ID13');

well first, that doesn't work, it returns "string is a class type and cannot be used as an expression", so I changed it to:

Private Property result as string

result = c.addListener('ID13');

I get "Expression Expected" at the open parenthesis.
What functions do you see listed in Intellisense when you type "c." ?
Ok I think I've figured it out, I think it was due to me using single quotes instead of double quotes. I think I have one last issue and I will have this fully function.

I have set result to a string, but it appears it wants to be of type "ServiceReference1.event".  How do I convert that to a string?  I tried result.toString but it didn't work.  Almost there!  
Think I have it figured out now. Thanks Kaufmed!