473,385 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Calling web services from C#


Here is a simple web service request written in Python:

rom SOAPpy import WSDL
wsdlFile = 'http://www.xmethods.net/sd/2001/TemperatureService.wsdl'
server = WSDL.Proxy(wsdlFile)
server.getTemp('90210')

What is the most elegant way to write this in C#?

--
Dr Jon D Harrop, Flying Frog Consultancy
The OCaml Journal
http://www.ffconsultancy.com/product...ournal/?usenet
Jul 5 '07 #1
8 13529
Jon,

In your project, right click on "references" and select "Add Web
Reference". In there, place the URL for the WSDL file, and then it should
add a file to your project which has the proxy which you can call the
getTemp method on.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jon Harrop" <jo*@ffconsultancy.comwrote in message
news:46**********************@ptn-nntp-reader02.plus.net...
>
Here is a simple web service request written in Python:

rom SOAPpy import WSDL
wsdlFile = 'http://www.xmethods.net/sd/2001/TemperatureService.wsdl'
server = WSDL.Proxy(wsdlFile)
server.getTemp('90210')

What is the most elegant way to write this in C#?

--
Dr Jon D Harrop, Flying Frog Consultancy
The OCaml Journal
http://www.ffconsultancy.com/product...ournal/?usenet

Jul 5 '07 #2
On Jul 5, 9:29 am, Jon Harrop <j...@ffconsultancy.comwrote:
Here is a simple web service request written in Python:

rom SOAPpy import WSDL
wsdlFile = 'http://www.xmethods.net/sd/2001/TemperatureService.wsdl'
server = WSDL.Proxy(wsdlFile)
server.getTemp('90210')

What is the most elegant way to write this in C#?

--
Dr Jon D Harrop, Flying Frog Consultancy
The OCaml Journalhttp://www.ffconsultancy.com/products/ocaml_journal/?usenet
Add a Web Reference which will get you a proxy class and use that to
get to the methods easily in code.

Here's a sample from a google search I did -
http://www.codeproject.com/cs/webser...ceconsumer.asp

- Pramod Anchuparayil

Jul 5 '07 #3
Pramod Anchuparayil wrote:
Here's a sample from a google search I did -
http://www.codeproject.com/cs/webser...ceconsumer.asp
All of the examples I've found (including this one) don't work.
Add a Web Reference which will get you a proxy class and use that to
get to the methods easily in code.
Using the "add web reference" certainly seems to be the right trick but I
still can't get a single call to actually work... :-(

Thanks though.

--
Dr Jon D Harrop, Flying Frog Consultancy
The OCaml Journal
http://www.ffconsultancy.com/product...ournal/?usenet
Jul 5 '07 #4
What happens when you call the proxy?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jon Harrop" <jo*@ffconsultancy.comwrote in message
news:46**********************@ptn-nntp-reader02.plus.net...
Pramod Anchuparayil wrote:
>Here's a sample from a google search I did -
http://www.codeproject.com/cs/webser...ceconsumer.asp

All of the examples I've found (including this one) don't work.
>Add a Web Reference which will get you a proxy class and use that to
get to the methods easily in code.

Using the "add web reference" certainly seems to be the right trick but I
still can't get a single call to actually work... :-(

Thanks though.

--
Dr Jon D Harrop, Flying Frog Consultancy
The OCaml Journal
http://www.ffconsultancy.com/product...ournal/?usenet

Jul 5 '07 #5
Nicholas Paldino [.NET/C# MVP] wrote:
What happens when you call the proxy?
For that example I get a 404. Adding a web reference to my own project seems
to autogenerate code for *CompletedEventArgs and *CompletedEventHandler but
not the actual call itself. Also, Intellisense doesn't display any useful
type information so I can't see how to invoke the RPCs.

Looking at the source code for the examples (that don't work), it seems that
adding a web reference is supposed to just generate a class with the
necessary members but that hasn't worked with the wsdl's that I've tried so
far.

I am particularly interested in examples for scientific computing. The vast
majority of this work is done on Linux, of course. Could it be that .NET
simply isn't compatible?

--
Dr Jon D Harrop, Flying Frog Consultancy
The OCaml Journal
http://www.ffconsultancy.com/product...ournal/?usenet
Jul 5 '07 #6
"Ethan Strauss" <ethan dot strauss at Promega dot comwrote:
I don't know the answer to your specific question below, but I can
tell
you that there are quite a few bioinformatics web services that work with
C#. I use NCBI's stuff quite a bit
(http://www.ncbi.nlm.nih.gov/entrez/q...soap_help.html) and I
have used others. If there is something specific you need to do (in C#. I
have no clue about F#), let me know and maybe I can help.
Ethan
Fantastic, thank you.

--
Dr Jon D Harrop, Flying Frog Consultancy
The OCaml Journal
http://www.ffconsultancy.com/product...ournal/?usenet
Jul 8 '07 #7
Jon Harrop wrote:
Pramod Anchuparayil wrote:
>Here's a sample from a google search I did -
http://www.codeproject.com/cs/webser...ceconsumer.asp

All of the examples I've found (including this one) don't work.
Your original one does:

C:\>type ws.py
from SOAPpy import WSDL
wsdlFile = 'http://www.xmethods.net/sd/2001/TemperatureService.wsdl'
server = WSDL.Proxy(wsdlFile)
print server.getTemp('90210')

C:\>python ws.py
-999.0

C:\>wsdl /language:cs
http://www.xmethods.net/sd/2001/TemperatureService.wsdl
Microsoft (R) Web Services Description Language Utility
[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.
Warning: This web reference does not conform to WS-I Basic Profile v1.1.
R2706: A wsdl:binding in a DESCRIPTION MUST use the value of "literal"
for the use attribute in all soapbind:body, soapbind:fault,
soapbind:header and soapbind:
headerfault elements.
- Input element soapbind:body of operation 'getTemp' on portType
'TemperatureBinding' from namespace
'http://www.xmethods.net/sd/TemperatureService.wsdl'.
- Output element soapbind:body of operation 'getTemp' on portType
'TemperatureBinding' from namespace
'http://www.xmethods.net/sd/TemperatureService.wsdl'.

For more details on the WS-I Basic Profile v1.1, see the specification
at http://www.ws-i.org/Profiles/BasicProfile-1.1.html.

Writing file 'C:\TemperatureService.cs'.

C:\>type ws.cs
using System;

public class Test
{
public static void Main(string[] args)
{
TemperatureService ts = new TemperatureService();
Console.WriteLine(ts.getTemp("90210"));
}
}

C:\>csc ws.cs TemperatureService.cs
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

C:\>ws
-999

Arne
Jul 8 '07 #8
Jon Harrop wrote:
Jon Harrop wrote:
>I am particularly interested in examples for scientific computing. The
vast majority of this work is done on Linux, of course. Could it be that
.NET simply isn't compatible?

Turns out this was correct. Most of the scientific databases are hosted on
Linux boxes and .NET is not yet compatible with them so you can't access
them from Windows.
SOAP and HTTP are standards.

It does not matter whether the server is running Windows or
Linux or IBM mainframe.

It is possible to implement a standard badly, but it is
still not the operating system that is to blame then - it
is the web service toolkit used server side.

And I have personal experience for that a widely used
web service toolkit like Axis works fine with .NET

Arne
Jul 8 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: c | last post by:
So far it looks like we have these options for calling our java based API from a .NET application: 1) http://www.jnbridge.com, about $500 per machine/developer 2) re-write java app in Visual...
0
by: Michael Brandt Lassen | last post by:
Hi gurus This problem is about calling Web services secured by Forms Authentication from Windows Forms user controls embedded in HTML. Using the object tag I’ve managed to include a Windows...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
1
by: Gregory Hassett | last post by:
Hi, I have a web service called GetComputerNameAndDescription which I can call from the main thread of my app. If I call it from a separate thread, however, it hangs on the call to Invoke() -- but...
0
by: Cleo | last post by:
Hi, I am trying to call a WebService Method written in Weblogic from VB.NET and I am getting the following error. I am using SOAP Caal s from VB.NET. Please find the wsdl file and my code. ...
3
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb)....
7
by: Stu | last post by:
Hi, I have a web service which returns a record set and works well integrated with an asp dot net page. However if I decided to develop a unix app will i be able to read the dataset as it is...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
1
by: jens Jensen | last post by:
Hello , i'm calling a webservice generated with oracle webservice java tools. I'm not able to add a web reference to a .net client the usual way with visual studio 2005. I was therefore...
3
by: Blasting Cap | last post by:
I'm using VS 2005, SQL 2005 reporting services. SQL reporting services is working, and I have it both on my local computer, as well as on a server. I've created a report in the SQL Business...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.