Let’s say I have both the Production and Sandbox environments.
There are differences between the two – let’s just say Sandbox has more modules installed, or the other way around.
I then generate a WSDL from Sandbox, add the Service Reference based on that WSDL and proceed to code up my application in .NET. The .NET application however uses only the methods which would be common to both Sandbox and Production environments, such as login(), query(), using the standard objects such as Lead etc.
Can I simply change the endpoint to point to Production and expect what I coded to work?
Yes. If the methods you are calling has same signature in both environment, nothing will cause the problem. If you alter the signature of the methods in service contract, that will cause runtime exception.
Also I would like to comment, if you change (ONLY addition of new members) the data contracts for these Service Methods, it will also work fine. For this to work, your service needs allow ExtensionDataObject. Any extra data from client will be stored in this object on the server.
Hope it answers your question.