Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

.NET WSDL Genericism Problem

Posted on 2011-09-21
3
Medium Priority
?
373 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

648 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