0

We are building application which communicates with another application via soap web services. The other application is developed by another company using PHP. Our app is client to their web service.

We have testing environment where we connected our apps and everything worked fine. Then we moved to production env. But their web service namespace is generated automatically based on URL, so namespace in test and prod env are mismatched.

I generated SOAP client with svcutil once more for production, but when I deploy my solution to test env, I can't connect to their web service. They also are not willing to change anything.

Is it possible to change namespace of web service client during runtime based on endpoint address?

2
  • their web service namespace is generated automatically based on URL. Sounds like a pretty horrible idea in case you want to move the service to a new location without breaking every client. Commented Oct 5, 2012 at 16:57
  • Which is exactly same thing we told them but they dont bother. We are also cooperating with other companies and we already made few deployment of same set of webservices and there was no problem. But they use c# service model as well. Commented Oct 5, 2012 at 18:20

1 Answer 1

2

As far as I know, you can't change the namespace at runtime. The obvious option that would definitely work would probably be to do it at compile time, something like;

#if PRODUCTION
[ServiceContract(Namespace = "MyProduction Namespace", Name = "PhpServiceContract")]
#else
[ServiceContract(Namespace = "MyTest Namespace", Name = "PhpServiceContract")]
#endif

If you're using it in multiple places and don't want to #if everywhere, just move it to a constant;

[ServiceContract(Namespace=Definitions.CURRENT_NAMESPACE, Name = "PhpServiceContract")]

and then just define it in one place;

public static class Definitions
{
#if PRODUCTION
    public const string CURRENT_NAMESPACE = "MyProduction Namespace";
#else
    public const string CURRENT_NAMESPACE = "MyTest Namespace";
#endif
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.