Call webservice from vb.net

I have a wsdl file that I added a reference to in my project how do I actually call the service through a forms application?
cobolinx1Asked:
Who is Participating?
 
Deepu SreedharConnect With a Mentor BI Software EngineerCommented:
See the picture attached. and let me know if you need more help on this.
WSE.JPG
0
 
illusioConnect With a Mentor Software Architect / Team LeaderCommented:
If you did "Add service reference" and you browsed to your WSDL file and it then added a service reference, then you use the selected namespace to search for the class ending on "client".
you do:

Using client as blablablaClient = new blablablaClient() ' or new blablablaClient(someweirdUrl)
       client.AVeryCoolMethod(SomeReallyUseFullArguments)
End Using

0
 
käµfm³d 👽Commented:
Right-click your project in Solution Explorer and then select Add Service Reference. In the address field, enter the path to your WSDL file and then click Go. In a few seconds, you should see your service listed under Services. Select it, change the Namespace if you like, then click OK.

Alternatively, I believe you can add the WSDL to your project as a New Item, then perform the above. Instead of entering the path to the file, you would click Discover, and then Services in Solution. The remaining steps are the same.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
roxviperCommented:
0
 
cobolinx1Author Commented:
This appears to be calling it:

Using client as blablablaClient = new blablablaClient() ' or new blablablaClient(someweirdUrl)
       client.AVeryCoolMethod(SomeReallyUseFullArguments)
End Using


But I get the following error message:
No Security header in message but required by policy.

0
 
cobolinx1Author Commented:
I have a username and password if it needs it but how would I add it?
0
 
cobolinx1Author Commented:
I added a username and password but still get the No Security header in message but required by policy error message.
client.ClientCredentials.UserName.UserName = "myid"
 client.ClientCredentials.UserName.Password = "mypwd"
0
 
käµfm³d 👽Commented:
Does your web service require certificate authentication?
0
 
cobolinx1Author Commented:
It looks like its just looking for the security token username and password... isn't that the same as the client credentials?
0
 
cobolinx1Author Commented:
No I confirmed it doesn't require certificate authentication.
0
 
illusioSoftware Architect / Team LeaderCommented:

Try using the wsHttpBinding binding with message security on.
Or post your WSDL is that doesn't do the trick. In the WSDL the required tokens can be read - very obscure  things, created to make you feel miserable.
0
 
cobolinx1Author Commented:
I don't know what you mean


Using client as blablablaClient = new blablablaClient() ' or new blablablaClient(someweirdUrl)
       client.AVeryCoolMethod(SomeReallyUseFullArguments)
client.ClientCredentials.UserName.UserName = "myid"
 client.ClientCredentials.UserName.Password = "mypwd"
End Using
0
 
cobolinx1Author Commented:
Sorry I don't know what you mean how would implement that??


Here is the part in the wsdl that I think the username and password are passed to

<wsp:Policy s0:Id="Auth.xml">
<wssp:Identity xmlns:wssp="http://www.bea.com/wls90/security/policy">
<wssp:SupportedTokens>
<wssp:SecurityToken TokenType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken">
  <wssp:UsePassword Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText" />
  </wssp:SecurityToken>
  </wssp:SupportedTokens>
  </wssp:Identity>
  </wsp:Policy>

Using client as blablablaClient = new blablablaClient() 
client.ClientCredentials.UserName.UserName = "myid"
 client.ClientCredentials.UserName.Password = "mypwd"
       client.AVeryCoolMethod(SomeReallyUseFullArguments)
End Using

Open in new window

0
 
Deepu SreedharBI Software EngineerCommented:
You should use WSE tool (which can be downloaded from Microsoft) to configure your .config file to insert a policy file that uses Username & Password Credentials.
0
 
illusioConnect With a Mentor Software Architect / Team LeaderCommented:
Creating a service reference normally adds some text to the app.config (or web.config) file. In there you find the ABC (Address, Binding, Contract). You see what type of binding that is being used. Put it on wsHttpBinding. To make things less complicated you can use the WCF Configuration Editor (it's under Tools in the visual studio), then open your config file and you'll have a nice gui to change your config. In that gui change the BasicHttpBinding to WsHttpBinding and try again.
From what I see, username and password is all it asks. So on that part you are on the right track.

0
 
cobolinx1Author Commented:
I tried switching to wshttpbinding and got the error below. I switched it back to custom and I get the No Security header in message but required by policy.

Downloaded the wse 3.0 and opened up the config file checked the first checkbox... went to tools and put in user name and password. It asked for a certificate which I dont know why but I put my user certificate in and it did create a policy. Still doesn't seem to work though.


"The content type text/xml; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 895 bytes of the response were: '<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:VersionMismatch</faultcode><faultstring>BEA-382032: The message must be an instance of: {http://schemas.xmlsoap.org/soap/envelope/}Envelope</faultstring><detail><con:fault xmlns:con="http://www.bea.com/wli/sb/context"><con:errorCode>BEA-382032</con:errorCode><con:reason>The message must be an instance of: {http://schemas.xmlsoap.org/soap/envelope/}Envelope</con:reason><con:details><err:InvalidEnvelope xmlns:err="http://www.bea.com/wli/sb/errors"><err:localpart>Envelope</err:localpart><err:namespace>http://www.w3.org/2003/05/soap-envelope</err:namespace></err:InvalidEnvelope></con:details><con:location><con:path>request-pipeline</con:path></con:location></con:fault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>'."

Open in new window

0
 
illusioConnect With a Mentor Software Architect / Team LeaderCommented:
Ok - so that proves that your webservice is in running SOAP 1.1 :-)  (basicHttpBinding)
That still leaves your error. I'm sorry but without extended investigation of the service itself I have no more options to guess for the solution.
You better contact the creator of the service you are trying to consume to know what options they additionally need. There is some data you can add to the soap header (all methods for that can be found in the client proxy you successfully created). But without any specification about what they expect, ... it's a wild goose chase.

I'm very sorry - not all answers can be satisfying.

If you the service you are trying to connect to is publicly accessable (which I doubt) and you tell us which one it is, we can provide you quickly the correct response.
0
 
Deepu SreedharBI Software EngineerCommented:
after setting the policy in the config file, if you can enable tracking in the last tab, it will give you the incoming & outgoing request/response in respective files, which you can use it for finding the fault on outgoing request.
0
 
cobolinx1Author Commented:
There was a specific security heading that I had to put in the config file. Thanks for your help I was going crazy!!!
0
 
illusioSoftware Architect / Team LeaderCommented:
You're welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.