0

I decided to migrate my legacy web service over to a WCF service called ServiceZ.svc. While moving things over went off without any issues and the application compiles AND I have other WCF TCP services running on my development machine, I cannot get this HTTP WCF service to load. I keep getting 404 errors no matter what I try - can somebody please review the included web.config section and help me figure out what is wrong? Thanks!

<system.serviceModel>  
    <services>  
      <service name="ServiceZ">  
        <endpoint address="http://localhost/Website/ServiceZ" binding="basicHttpBinding"
          name="MainHttpPoint" contract="IServiceZ" />  
        <endpoint address="mex" binding="mexHttpBinding" name="MexEP"  
          contract="IMetadataExchange" />  
        <host>  
          <baseAddresses>  
            <add baseAddress="http://localhost/Website/ServiceZ" />  
          </baseAddresses>  
        </host>  
      </service>  
    </services>  
    <bindings>  
      <basicHttpBinding>  
        <binding openTimeout="0:10:00" sendTimeout="00:10:00" />  
      </basicHttpBinding>  
    </bindings>  
    <behaviors>  
      <serviceBehaviors>  
        <behavior>  
          <serviceMetadata httpGetEnabled="true" />  
          <serviceDebug includeExceptionDetailInFaults="false" />  
        </behavior>  
      </serviceBehaviors>  
    </behaviors>  
  </system.serviceModel>
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
Ken Tola
  • 671
  • 1
  • 8
  • 18
  • A reboot of IIS suddenly cleared up the 404 errors. Now I am having an issue where the WSDL is downloaded but breaks due to local references: The document was understood, but it could not be processed. - The WSDL document contains links that could not be resolved. - There was an error downloading 'http://MyServer/ServiceZ.svc?wsdl=wsdl0'. - The remote name could not be resolved: 'MyServer' This occurs in Production but I have a full URL listed - i.e. www.prodserver.com - so why the local references? – Ken Tola Feb 21 '11 at 20:04
  • I don't know, but it's a separate question. Please ask separately. – John Saunders Feb 21 '11 at 20:22

1 Answers1

1

Depending how you want to configure this, you can take the following approach:

1) In the serviceBehaviors I tend to add the following within the behavior: (completely optional)

<useRequestHeadersForMetaAddress>
  <defaultPorts>
    <add scheme="http" port="__PORT__" />
  </defaultPorts>
</useRequestHeadersForMetaAddress>

This makes the service accessible with either a query using localhost, localserver1, www.webserver2.com, or fully.qualified.domain.com. (Makes for less headaches IMHO).

2) The endpoint addresses are relative to the baseAddress. That as to say you can use address="" for your default binding and address="mex" for your mexHttpBinding, given that baseAddress="http://localhost:__PORT__/Website/ServiceZ"

Most likely your WSDL problem is due to a mix of the two problems (basically, the service is saying all markup can be found on localhost (as specified by the endpoint address)--which is true when you run it locally, however when it's on a remote server this is no longer the case)

Brad Christie
  • 100,477
  • 16
  • 156
  • 200
  • I apologize but now I am faced with another issue that I have not seen before. When I created me proxy class, the class generated Request and Response operations for everything. For example GetResultRequest and GetResultResponse. When I try to call myProxy.GetResult, I am being asked to pass in a GetResultRequest class - this is clearly way too complicated - what do I do wrong? – Ken Tola Feb 21 '11 at 21:15
  • @KenTola: I'm not sure I understand the question. Can you maybe post some demo code (the problem area) in your question as an edit? I'll be glad to help with more information. – Brad Christie Feb 21 '11 at 21:25
  • I appreciate the help - I had thought this would be straightforward but going from a classic web service to WCF sucks. I had read that I needed to add Factory="System.ServiceModel.Activation.WebServiceHostFactory" to the svc file to host things in IIS and then I need to add WebInvoke(BodyStyle = WebMessageBodyStyle.WrappedRequest) to the OperationContract attributes. I did that and now I get Endpoint Not Found when trying to get to the service... – Ken Tola Feb 21 '11 at 21:45
  • @KenTola: Are you grabbing the WSDL yourself or using the "Add Service" functionality of VS? – Brad Christie Feb 21 '11 at 21:51
  • I am using Visual Studio - that is where the Request and Response class stuff was found. I then tried changing things up and I then got "request body parameters to be serialized without any wrapper elements. At most one body parameter can be serialized without wrapper elements" which led me down the whole WebServiceHostFactory path... – Ken Tola Feb 21 '11 at 21:54
  • Sorry - fat-fingered things. I also see that the Windows 2008 server has WCF Activation enabled - is that correct? – Ken Tola Feb 21 '11 at 21:55
  • I reverted everything back to the original state but I still have to pass in Request and Response classes for everything - how can I overcome that issue? – Ken Tola Feb 21 '11 at 22:02
  • @KenTola: That's what WCF is going to do: whatever your prototypes include for argument types and return types, those types need to be used in the calls. .NET takes those classes and serializes them in on the request, then deserializes them on the response (to and from those objects specified by the contract). I guess it really just depends on what kind of behavior you're expecting to occur and what you need accomplished. – Brad Christie Feb 21 '11 at 22:08
  • If I go from basicHttpBinding to webHttpBinding I get the error "request body parameters to be serialized without any wrapper elements. At most one body parameter can be serialized without wrapper elements" – Ken Tola Feb 21 '11 at 22:08
  • I am not passing any custom classes - just integers and strings. There is nothing overtly special about the contract so why is this so difficult? I can create a standard ASMX web service in 2 minutes, pass in various string and integer values, return a string response and there are no issues. Now, with the Microsoft "upgrade", I have to create 3 classes to do the same thing?!? – Ken Tola Feb 21 '11 at 22:10
  • @KenTola: You must be new to Microsoft software. ;-) MS is revolting against IBM's "KISS". Can you post your prototype and what you have at least so I can see it? Hard to diagnose without see the issue. – Brad Christie Feb 21 '11 at 22:14
  • Ha - I have been programming in MS since 1994 - I just never moved on to the WCF garbage as it is so overly complicated given its non-existent benefits for web services. This whole issue was spawned in response to my ASMX service throwing 405 errors when trying to connect to it via a proxy. Here is the wsdl - http://www.ipghoster.com/GhostServiceX.svc?wsdl=wsdl0 - when I try to use the service, I get an error telling me no endpoint exists. – Ken Tola Feb 21 '11 at 22:26
  • @KenTola: Out of curiosity, does the WcfTestClient work without any hitches? (usually found @ "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\WcfTestClient.exe") – Brad Christie Feb 21 '11 at 22:36
  • It adds the service with no issues but when I try to invoke any method I get "There was no endpoint listening" errors – Ken Tola Feb 22 '11 at 00:16
  • @KenTola: interesting. Are you keeping it bound to port 80? – Brad Christie Feb 22 '11 at 00:23
  • Yeah - I figured it out - IIS did not have a .svc MIME type. Once I added that in then I could reach the service with no issues. Here is an article on it although I added the MIME type directly in the IIS Management Console - http://technet.microsoft.com/en-us/library/dd632554.aspx – Ken Tola Feb 22 '11 at 01:10
  • @KenTola: Awesome, glad to hear it. I recommend editing your question with the steps you took to eliminate the problem though, so anyone else that comes across it can find the solution. But kudos for being persistent! ;-) – Brad Christie Feb 22 '11 at 01:16