Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top