Solved

Calling a Web Service in VB.NET

Posted on 2014-11-19
9
249 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 33

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 33

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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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
 

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 33

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 33

Expert Comment

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

-saige-
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

773 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