Solved

Calling a Web Service in VB.NET

Posted on 2014-11-19
9
245 Views
Last Modified: 2014-11-19
Afternoon All,

PLEASE can someone help me before I go stir crazy in trying to figure this out. I am a SQL DBA that has self taught myself some VB.NET to interact with the SQL databases we have in-house for data input etc.

I have a web service that I am trying to build a 'Loader' for as the provided Java based one the company in question gave us cannot deal with multiple files and can only deal with one file at a time.

https://openinterchange.openecommerce.co.uk/OpenInterchange/OpenInterchange?wsdl

This is the URL of the WSDL. I have some automation software that has an inbuilt WebService/WCF Executer, while this is great to look at and does the job it doesn't work with my .NET so I am having to do this myself manually.

Essentially I need to fire some XML using a particular FUNCTION from the above WSDL to return a response to my application.

Now according to the automation program it uses the 'OpenInterchange' Class and then uses the OpenInterchange.XStreamMessage(x,x,x,x,1) METHOD to return the information.

I ended up with something along the lines of

        Dim MyService As New XstreamUAT.xStreamMessageRequest(brokreftxtbx.Text, bnumtxtbx.Text, lickeytxtbx.Text, "This", 30)

        Dim MyResult As New XstreamUAT.xStreamMessageResponse(MyService.ToString)

        MsgBox(MyResult)

Open in new window


But I'm getting nothing, I am obviously completely missing the point. I can't give you details to login to their WSDL but with the link I think there is enough information there to point me in the right direction.

All help appreciated.
0
Comment
Question by:Lynchie435
  • 5
  • 4
9 Comments
 
LVL 32

Expert Comment

by:it_saige
ID: 40452399
Have you already added a Service Reference to your project or used the wsdl utility to generate the service proxy class?

-saige-
0
 

Author Comment

by:Lynchie435
ID: 40452404
I have already added a Service Reference. :)
0
 
LVL 32

Accepted Solution

by:
it_saige earned 500 total points
ID: 40452491
Have you created the OpenInterchangeClient?

Example -
Sub Main()
	Dim client As New ServiceReference1.OpenInterchangeClient("There needs to be something here", "And possibly something here") ' Depended upon your constructor usage.
	Dim return = client.xStreamMessage(brokreftxtbx.Text, bnumtxtbx.Text, lickeytxtbx.Text, "This", 30)
End Sub

Open in new window


-saige-
0
 

Author Comment

by:Lynchie435
ID: 40452534
Hi Saige,

I tried

        Dim client As New XstreamUAT.OpenInterchangeClient("XstreamUAT", "https://www.openinterchange.co.uk/OpenInterchange/OpenInterchange?wsdl") ' Depended upon your constructor usage.
        Dim strresult = client.xStreamMessage(brokreftxtbx.Text, bnumtxtbx.Text, lickeytxtbx.Text, "This", 30)

Open in new window


But it returned :

Could not find endpoint element with name 'XstreamUAT' and contract 'XstreamUAT.OpenInterchange' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:Lynchie435
ID: 40452590
Saige - you put me in the right ballpark.

2 Lines of code is all it took!

        Dim client As New XstreamUAT.OpenInterchangeClient()
        XMLResponseTxtBx.Text = client.xStreamMessage(brokreftxtbx.Text, bnumtxtbx.Text, lickeytxtbx.Text, "This", 10)

Open in new window

0
 

Author Closing Comment

by:Lynchie435
ID: 40452591
Put me in the right ballpark!
0
 
LVL 32

Expert Comment

by:it_saige
ID: 40452607
This might be closer to what you are looking for:
Imports System.ServiceModel

Module Module1
	Sub Main()
		'Specify the binding to be used for the client.
		Dim binding As New BasicHttpBinding(BasicHttpSecurityMode.Transport)

		'Specify the address to be used for the client.
		Dim address As New EndpointAddress("https://openinterchange.openecommerce.co.uk:443/OpenInterchange/OpenInterchange")

		' Create a client that is configured with this address and binding.
		Dim client As New ServiceReference1.OpenInterchangeClient(binding, address)
		Dim [return] As String = client.xStreamMessage("test1", "test2", "unlicensed", "This", 30)
		Console.WriteLine([return])
		Console.ReadLine()
	End Sub
End Module

Open in new window


Produces the following output for me:Capture.JPG
Which we know is invalid for your use, but proves that I am getting a response from the service.

-saige-
0
 

Author Comment

by:Lynchie435
ID: 40452615
Saige - you are a gentleman and a scholar :)
0
 
LVL 32

Expert Comment

by:it_saige
ID: 40452617
Not a problem.  Glad I was able to assist.  ;)

-saige-
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video discusses moving either the default database or any database to a new volume.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now