Solved

WSDLs with same definition

Posted on 2011-02-25
2
493 Views
Last Modified: 2012-05-11
Hello,

We are using the PayPal Pro service and they have two different WSDLs, one for testing (sandbox) and one for production (live).  They are located at two different urls but have the exact same definition, as of now at least.

 We are using C# 4.0 and consuming them as a Service Reference in our back-end class library.  Then our web application makes as normal to the back-end in order to process payment.

Our issue is how to handle switching between definitions and endpoint locations?  We would like to be able to set some web.config app key value to determine if its should use the Test (sandbox) WSDL or the live WSDL but not sure how to do this.

It seems that we should be able to handle the endpoint as a config value and grab that when we build a request.  So I guess are main issue is understanding how to use the definitions themselves.  We want to just use one instance of a payment class and method(s) to make the calls but when we "import" both namespaces, there is ambiguity because they are same definition.  As such:

using PayPalSvc;
using PayPalSvcSandbox;

Doesn't really make sense to do it this way anyways.  So if we can't import both namespaces for the two different WSDLs it seems are choices are one of the following:

1. Create separate classes/methods and detect in the calling method which one to call.  Our issue here is we don't want redundant classes/methods.

2. Or just use one of the definitions since they are the same and call different endpoints.  Our issue here is there must be a reason there are separate WSDL locations.

Neither of these sound like a great solution.  Anybody have any ideas?  This can't be that unusual of a scenario where an external company has different WSDL definition locations for different environments.  

Thanks.
0
Comment
Question by:kruegerste
[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 Comments
 
LVL 6

Accepted Solution

by:
ksrsrinivasan earned 250 total points
ID: 34985752
You are in the right direction. Just add one service reference to the PayPal live URL.. and when making the actual call, decide on whether to use the Live/Test URL from your configuration.. a sample code would look like
var binding = new BasicHttpBinding();
var remoteAddress = new EndpointAddress("<your test/live URL>");
var client = new <PayPayClient>(binding, remoteAddress);

Open in new window

0
 
LVL 23

Assisted Solution

by:Siva Prasanna Kumar
Siva Prasanna Kumar earned 250 total points
ID: 34985760
The WSDLs in testing environment and live are same which make sense, depending on where you want to send the request to all you need to do is set/configure the endpoint to the exact target environment.

The advantage of the above approach is first you build you web app and test it thoroughly and when moving to production all you need to do is change the endpoint of your service client to the production web service endpoint.

Please check the below links about configuring the endpoints.

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/1b909664-2578-48f7-8e4b-31531637ba77/

http://bytes.com/topic/net/answers/696769-change-wcf-client-endpoint-address
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.

730 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