Solved

.NET WSDL Genericism Problem

Posted on 2011-09-21
3
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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