I was trying to make a couple of small changes to a WCF services recently and I hit a brick wall while trying to update my references to that service in a WP7 app. I was noticing that instead of using the local IP address it was filling in the machine name and then picking a random port for the WSDL declaration.
The screen shot to the left was what I would see. The WCF service was available http://127.0.0.1:81/Services/MyService.svc, however, the WSDL for the service was forced to http://[MACHINENAME]:82/Services/MyService.svc?wsdl. Now I added a host entry for my machine name at 127.0.0.1 but the WSDL is actually at port 82 (and would randomly select other ports). This is not a valid URL (on my machine) even with the service running and would fail all the time. I tried pointing directly to the correct and valid IP/port but all the references inside are porting to the wrong location.
The solution. Define a behavior and attach it to your service, you can use the behavior to lock in the port number as follows:
Comments are closed.