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?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
MeepMania
  • 103
  • 2
  • 13
  • 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](http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/threads) on MSDN. – John Saunders Dec 06 '13 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. – MeepMania Dec 07 '13 at 18:14
  • 1
    WSDL.EXE is part of the ASMX technology. – John Saunders Dec 07 '13 at 20:14

1 Answers1

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

Eugene S.
  • 3,256
  • 1
  • 25
  • 36
  • 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. – MeepMania Dec 06 '13 at 22:30
  • 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. – Eugene S. Dec 06 '13 at 22:53
  • -1 for suggesting a web reference instead of a service reference. – John Saunders Dec 06 '13 at 22:55
  • Service Reference makes more sense. For some reason I thought that this was ASMX service. Update coming. – Eugene S. Dec 06 '13 at 23:04
  • Implemented the code below and it works perfectly. Thank you for your efforts. :) – MeepMania Dec 07 '13 at 19:31
  • You can use a service reference even if it's an ASMX service. BTW, even after your edit, you're still talking about wsdl.exe. – John Saunders Dec 07 '13 at 20:14