Solved

.NET WSDL Genericism Problem

Posted on 2011-09-21
3
366 Views
Last Modified: 2013-12-17
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
Comment
Question by:EndersDev
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
gena17 earned 250 total points
ID: 36575287
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
 
LVL 2

Author Comment

by:EndersDev
ID: 36576708


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
 
LVL 2

Author Closing Comment

by:EndersDev
ID: 36576736
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now