It's been a long time since I worked with SOAP so my question might be trivial but I just wasn't able to find a satisfying answer so far!

Anyways here's what's going on:

  • I got access to a system via SOAP endpoints (Dev, Test and Prod)
  • I used svcutil to create proxy classes (they are almost identical, only few lines difference)
  • I created an interface for my SOAP operations and implemented one class for each environment (Dev/Test/Prod)

Now I do like that I have separate classes since we might do logging or whatever in a different manner in production environment, however the business logic is pretty much the same but reusing the code doesn't seem feasable... even though the generated classes are the same, they live in different namespaces and I don't really want to touch generated code!

If they used REST it wouldn't be a problem but I'm having trouble to solve this problem gracefully with SOAP. How would you approach this?

EDIT: I am aware that the obvious simple solution would be to generate proxy class only once and use them for all the environments. However I'm not sure if that's the right approach since the different endpoints might change (although I would prefer of course if the API provider would make sure they're always identical but not sure if that's always possible in real life scenarios!)

  • If they were different, what use would they be?
    – Caleth
    Commented Nov 7, 2022 at 11:19
  • Are you developing a different piece of software for all three environments? Or three variants of the same software which correspond to the three API endpoints, Or do you develop one software which can be configured to switch between the three endpoints?
    – Doc Brown
    Commented Nov 7, 2022 at 15:37
  • ... and I am not a SOAP expert. For a noob like me, can you please explain some details why for a REST API this would not be a problem, but for a SOAP API it is?
    – Doc Brown
    Commented Nov 7, 2022 at 15:38
  • 2
    "implemented one class for each environment (Dev/Test/Prod)" That is almost certainly not the right approach. You should be able to use a single class for all the environments. You can set the URL transparently via configuration, or set the URL with runtime logic (that would probably read configuration).
    – John Wu
    Commented Nov 8, 2022 at 0:02
  • 1
    If you're pulling WSDL files from prod vs test vs dev and they are different, they may be on different builds. You should ask your service provider which one you should be using. In most cases you should pull it from production, since that is guaranteed to be supported. Just build the one proxy from the agreed location and use that one. If there are environmental/compatibility issues that is a process issue, not something to be solved in your code. In most cases.
    – John Wu
    Commented Nov 8, 2022 at 8:36


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.