Reputation: 6217
Ok, installed Visual Web Developer 2008, Created a Website as ASP.net (C# Language), than added a Service to it via the following URL: http://ws.idssasp.com/members.asmx?wsdl and after hitting Go, looks like this (I change the namespace to ServiceMembers
):
Now it looks like this:
If I than go to Default.aspx.cs file, How do I use this on Page Load? I want something to be outputted from the Service on Page Load, ofcourse, will need to call something else via a button, but really just need a way to get anything from this service to be outputted... How to do this?
Looking here: http://ws.idssasp.com/members.asmx there are a bunch of methods that resemble the pic above, but how to use them anywhere? When I try to do Response.Write(ServiceMembers.GetCategoryListResponse);
if gives error that this is a Type and can not be used in that way. How do I use anything here?
Also, I will need to pass a Username
and Password
into the initial SOAP POST to that URL (which I have), before I can get anything back as a Response, but how? Looks like I should use ServiceMembers.AuthorizeHeader
somehow? But how? Looking at the Request XML from this page here for GetCategoryList
, has this listed in the XML:
<soap:Header>
<AuthorizeHeader xmlns="http://ws.idssasp.com/Members.asmx">
<UserName>string</UserName>
<Password>string</Password>
</AuthorizeHeader>
</soap:Header>
But how to do this via code to the server? Unknown!
I don't see GetCategoryList
Method as an option for ServiceMembers
namespace anywhere, but there is GetCategoryListRequest
Type and GetCategoryListResponse
Type as options for ServiceMembers
via the last pic. How do I invoke Methods of a Service? How do I use any of this for this step in the process? I have read so many tutorials on this, but nothing that I've seen explains how to do this without error of some sort, or different situations than mine.
Can anyone start me out with just simple code on outputting anything from this Web Service? Anything at all? Everyone is saying to use Visual Web Developer as it will do the Bulk of the work for you, but no one is explaining how to use any Web Service that you install. Seems that they only explain on how to use Specific things in Web Services, it's like they aren't teaching you to fish in an ocean of fish, but instead setting you up to fail, with a fish in a bucket that you are sure to catch.
What is the next step here? I didn't create this Web Service, and I don't know how to use it in the ASP.NET Website either.
Upvotes: 2
Views: 21386
Reputation: 14614
The GetCategoryList
method is in MembersSoapClient
class and you need to create an instance of MembersSoapClient
to use GetCategoryList
. Try this in your Page_Load
method:
protected void Page_Load(object sender, EventArgs e)
{
AuthorizeHeader authorizeHeader = new AuthorizeHeader();
authorizeHeader.UserName = "yourusername";
authorizeHeader.Password = "yourpassword";
MembersSoapClient client = new MembersSoapClient();
Category[] categories = client.GetCategoryList(authorizeHeader);
}
Upvotes: 2