• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

.NET WSDL Genericism Problem

I have been asked to integrate a client's Magento shopping cart by pulling orders into our system using SOAP. We are talking to a new client with the same request. My problem is, unlike other web references like amazon etc, this will require a unique web reference for each client hosting the magento code, but the methods, objects and algorithms that will be used are all the same.

How do I create a single class that can handle these generically?

Example of what I DON'T want to have to do:
using Company1MagentoRef;
using Company2MagentoRef;


...

if(company == company1)
{
    Company1MagentoRef.MagentoService man = new  Company1MagentoRef.MagentoService();

    string sessionId = man.login(username,apiKey);
    MagentoOrderEntity [] moe = man.getOrders(sessionId);
    // Do a bunch of processing
    man.EndSession();
}
else if(company == company2)
{
    Company2MagentoRef.MagentoService man = new  Company2MagentoRef.MagentoService();

    string sessionId = man.login(username,apiKey);
    MagentoOrderEntity [] moe = man.getOrders(sessionId);
    // Do a bunch of processing
    man.EndSession();
}

... etc

Open in new window

0
EndersDev
Asked:
EndersDev
  • 2
1 Solution
 
gena17Commented:
I think you can set the URL of the service dynamically just before using it.
You just need to set URL Behavior property to Dynamic.
See here: http://msdn.microsoft.com/en-us/library/tydxdyw9.aspx
0
 
EndersDevAuthor Commented:


In .Net 4.0 the URL behavior is already dynamic, so it was as simple as setting the URL property to point to the WS. (omitting the  ?wsdl  portion, for anyone else wanting to do the same)

Thanks
0
 
EndersDevAuthor Commented:
The solution gave enough that I knew what to research, but it could have been more direct (e.g.: "Set the URL property, and don't forget to drop the ?wsdl at the end of the URL if applicable")
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now