1

I'd like to use a web service from a database to gather informations. Right now, I implemented to web service, turned it into a proxy class via wsdl.exe but I'm slightly irritated by the outcome. The normal way to call that class is new object -> method -> parameters ->happiness. This thing only consists of partial classes and wants strange parameters. I'm not even sure if I got the right method to get the wanted information.

This seems to be the needed method:

public UniProtId2DomainIdsRecordType[] UniProtId2DomainIds   (UniProtId2DomainIdsRequestRecordType UniProtId2DomainIdsRequestRecord)
{
    object[] results = this.Invoke("UniProtId2DomainIds", new object[] {
                UniProtId2DomainIdsRequestRecord});
    return ((UniProtId2DomainIdsRecordType[])(results[0]));
}

This seems to be one of the needed classes:

public partial class UniProtId2DomainIdsRequestRecordType

{

private string uniprot_accField;

/// <remarks/>
public string uniprot_acc
{
    get
    {
        return this.uniprot_accField;
    }
    set
    {
        this.uniprot_accField = value;
    }
}

}

(That's the whole class, generated by wsdl.exe -> https://www.dropbox.com/s/yg909ibdq02js5a/GetCath.cs)

But as soon as I try to use it as I think it should work... well... my experiments on this (none of them working):

            UniProtId2DomainIdsRequestRecordType Uni2Cath = new UniProtId2DomainIdsRequestRecordType();
        Uni2Cath.uniprot_acc = "P0A7N9";
        UniProtId2DomainIdsRecordType[] UniProtId2DomainIds;
        UniProtId2DomainIdsRecordType test = new UniProtId2DomainIdsRecordType();
        test.uniprot_acc = "P0A7N9";
        UniProtId2DomainIdsRecordType[] UniProtId2DomainIds(test);

All I need is to get a string like P0A7N9 to be passed to the server.

(The reference to this webservice: http://api.cathdb.info/api/soap/dataservices/wsdl#op.o159501052 )

Can someone give me a hint how to handle this, please?

3
  • ASMX is a legacy technology, and should not be used for new development. WCF or ASP.NET Web API should be used for all new development of web service clients and servers. One hint: Microsoft has retired the ASMX Forum on MSDN. Commented Dec 6, 2013 at 22:55
  • Nice of you to mention but it doesn't change the fact that the database I NEED to use has their formats. Btw, I never mentioned using ASMX, neither did I add it to the tags. I don't code in asp.net, it's plain C# and the service adressed is SOAP over HTTP. Commented Dec 7, 2013 at 18:14
  • 1
    WSDL.EXE is part of the ASMX technology. Commented Dec 7, 2013 at 20:14

1 Answer 1

1

The easiest way would be to add this web service as Service Reference to your project. Then you can call the different methods. Use this as the address: http://api.cathdb.info/api/soap/dataservices/wsdl

using (var ser = new DataServicesPortTypeClient())
{
    var results = ser.UniProtId2DomainIds(new UniProtId2DomainIdsRequestRecordType
    {
        uniprot_acc = "P0A7N9"
    });

    if (results != null)
    {
        var geneName = results.gene_name;
        var speciesName = results.species_name;
    }
}

If you want to use your generated class do this:

using (var service = new DataServices())
{
    var results = service.UniProtId2DomainIds(new UniProtId2DomainIdsRequestRecordType
    {
        uniprot_acc = "P0A7N9"
    });

    if (results != null && results.Length >0)
    {
        var geneName = results[0].gene_name;
        var speciesName = results[0].species_name;
    }
}

As John suggested in the comments, ASMX and wsdl.exe are deprecated technologies. You should be using Service References and svcutil.exe

Sign up to request clarification or add additional context in comments.

6 Comments

That might work but how do I get the answer? It's an array that consists of six strings. And I really would like to know how to use that generated class in case I want to use other methods than uniprot to cath.
I updated the answer with some ideas. The generated Web Reference has all of the methods that service exposes, you will be able to use them. The Web Reference generates the same classes as wsdl.exe, it's just nicer, because you let VS handle it, as opposed to command line.
-1 for suggesting a web reference instead of a service reference.
Service Reference makes more sense. For some reason I thought that this was ASMX service. Update coming.
Implemented the code below and it works perfectly. Thank you for your efforts. :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.