Reputation: 1039
I have created a new WCF web service and but when i try to run it, I get this error
No code was generated.If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or servicesor because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.
My web.config
looks like
<services>
<service name="namespace.serviceName"
behaviorConfiguration="MyServiceTypeBehaviors" >
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
Background is, I have been given a dll
from a third party and I created a new web service so that I can implement all the interface methods needed, but when I try to run this web service through Visual Studio, I get the error shown above.
If I directly run website.com/folder/serviceName.svc
, I see the service but clicking on it doesn't do anything.
Update: I have fixed the above error my making some changes in web.config
file but now when I run my service, I get no method (I am using Visual Studio inbuilt WcfTestClient)
Upvotes: 5
Views: 11686
Reputation: 506
This problem still persists in VS2022. Turns out by unticking "reuse types in referenced assemblies" and deleting both obj and bin directories helps.
Upvotes: 30
Reputation:
I think you need to add a contract interface with the correct ServiceMethod attributes to this as shown here http://msdn.microsoft.com/en-us/library/ms731835(v=vs.110).aspx
This will allow the internals of WCF to generate a wsdl for you, and that will allow svcutil.exe to generate client code for you as well.
Forgot to mention that you will want your service to inherit from it as well so perhaps you can infer it from namespace.serviceName?
Also, don't forget DataContract and ServiceContract attributes on your interface.
Upvotes: 2