views:

243

answers:

4

Note: I am just consuming webservice I have no control over webservice code.

So in .net 2.0 I reference the webservice and see a class in the webservice namespace, say foobar. It's defined as:

public class foobar : System.Web.Services.Protocols.SoapHttpClientProtocol

but in .net 3.5 when i add a reference to the same webservice I no longer have this foobar class available. I do see foobarSoap which is an interface which exposes all of the methods in the foobar class above. It's defined as:

public interface foobarSoap

However it doesn't expose the properties (for obvious reasons).

I need to access these properties. How do I do it?

+1  A: 

You can try using the Web Service Description Language Tool (Wsdl.exe) to generate an actual class file:

wsdl.exe /language:cs http://www.example.com/FooService.wsdl

You can get more information about the WSDL Tool on it's MSDN Page.

Andrew Moore
A: 

I have a sneaky feeling that the properties will not be part of the service definition (WSDL) which would mean you may not be able to use them. If possible try to convince who ever maintains the service to expose the properties as actual methods.

It is quite likely that you will be unable to access the properties in which case you may just be out of luck. Sorry.

I am going to try exposing a property and then I will report the results back here.

EDIT: Cannot expose an interface property using WCF, it simply will not compile

[ServiceContract]
public interface IFooService
{
    [OperationContract] // This is not allowed, it will not compile
    string Name { get; set; }
}

EDIT: Cannot be done using ASMX web services either. : (

[WebService(Namespace = "http://tempuri.org/")]
public class FooService : System.Web.Services.WebService
{
    [WebMethod] // This is not allowed, it will not compile
    string Name { get; set; }
}
smaclell
A: 

I just created a sample project and created a web proxy to the service, using the Add Service Reference menu:

http://www.xmlme.com/WSShakespeare.asmx

Visual Studio 2008 generated an interface and a proxy class based on the WSDL. For example, I have a class ShakespeareSoapClient that implements an interface ShakespeareSoap.

It seems to work fine. Am I missing something.

Jason Jackson
A: 

I had a similar problem when I upgraded from 2005 to 2008. I think what you are missing, when you click "Add Service Reference", a newer dialog comes up. click the Advanced button at the bottom, then on the next dialog that comes up, click the Add Web Reference button at the bottom, in the compatibility section. Then you'll get the dialog that you are most likely used to, and will have standard 2.0 proxy classes.

hmcclungiii