Patrick’s Bytes

Techie for the past 30 years…

Cryptic WCF service not found error

When your WCF service returns you the error “The type ‘MyNamespace.MyService’, provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.” The common culprit will inside the .svc file, you just double check the Code behind file or DLL are deployed in the bin folder. But one rarely known cause is that your WCF service can’t be activated due to missing dependency, which in my case today I realize I didn’t deploy the Sync Framework. So beware, WCF errors can be quite cryptic sometimes.

WCF – MSMQ based web service returns error 503

I added MSMQ to my WCF web service (which was running OK) by adding the following endpoint to the service in web.config file

<endpoint
    address="net.msmq://server/private/queue1"
    binding="netMsmqBinding"
    bindingConfiguration="MsmqConfiguration"
    contract="ITestQueue" />

I also added the following binding

<netMsmqBinding>
    <binding name="MsmqConfiguration"
       exactlyOnce="false">
       <security mode="None"/>
    </binding>
</netMsmqBinding>

Once I deployed the Wcf service on Windows Server 2008, I also enable net.msmq on the website using the following command

appcmd set app "localhost/service" /enabledProtocols:net.msmq

However when I try to point to the svc file from my browser I got an Error 503 instead. Removing the MSMQ endpoint and I have the service up and running again.

After that I have a look at the website via the IIS Management Console and I realize that http protocol is not enabled for the website anymore

image

A normal web app will have http protocol such as below

image

At last I figure out that the appcmd actually overwrote the settings instead of adding on to it. So the correct appcmd command is:-

appcmd set app "localhost/service" /enabledProtocols:net.msmq, http

And I have the site running again with both http and msmq protocol enabled.

How to deploy a WCF web service project onto IIS6/7

clip_image002

In your webservice project, you have PrecompiledWeb folder, this folder contain the web service project in compiled form. Copy the content of the PrecompiledWeb, which is the CustomXmlService folder in this case to c:\inetpub\wwwroot

clip_image004

Now the folder is a website in the web server (but without the ability to run .NET code) so go to your IIS manager console to make this website to a web application. In the console you will see that you newly copied folder does not have a globe icon.

clip_image006

You can see the website in your Default Web Site, in IIS7 right click and select Convert to Application.

clip_image008

Still inside IIS7, a new window will pops up, click OK to accept the settings.

clip_image010

For IIS6 right click to open up the property page of the website

image

A new window will pops up, showing the default Directory tab

image

What you need to do is to click on the Create button on the lower half of the window

image

Click OK if you are not changing the application pool or execute permissions. Leave the permission at Scripts only.

To test out the web service, open it inside browser and the service description will come out.

clip_image012

In Visual Studio client project, delete your project Service Reference and add a new one pointing to this deployed web site.

clip_image014

Workflow Services error: "Operation is not implemented by the service"

I been trying to solve this Workflow Services error on my IssueTracker project for 2 weeks without any progress. :(

Operation is not implemented by the service.
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)\r\n   at

System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)\r\n   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)\r\n   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)\r\n   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)\r\n\r\nException rethrown at [0]: \r\n   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\r\n   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)\r\n   at IssueTrackerTest.IssueProcessService.IIssueProcess.ProcessIssue(Issue issue)\r\n   at IssueTrackerTest.IssueProcessService.IssueProcessClient.ProcessIssue(Issue issue) in C:\\Workspace\\Projects\\IssueTracker\\IssueTrackerTest\\Service References\\IssueProcessService\\Reference.cs:line 285\r\n   at IssueTrackerTest.IssueProcessTest.TestProcessIssue() in C:\\Workspace\\Projects\\IssueTracker\\IssueTrackerTest\\IssueProcessTest.cs:line 88″    string

 

Until today I found this blog post by Damir Dobric.

While invoking an operation on the workflow’s web service you may get following error:

“Operation is not implemented by the service.”

To solve the problem take a look on the ContextToken property of the receive-activity of the workflow service.
If this property is set as shown on the picture below, remove the value, rebuild solution and start all again.

image

 

Thanks Damir for saving my days :)

Passing large files over WCF channel

If you want to pass large binary files via a WCF channel, you need to increase the maxStringContentLength on your WCF host app.config/web.config file. From my sample on my IssueTracker project, I added a new bindings element to the system.serviceModel section as below:
        <bindings>
            <wsHttpBinding>
                <binding name=”WSHttpBinding_IDataService” closeTimeout=”00:01:00″
                    openTimeout=”00:01:00″ receiveTimeout=”00:10:00″ sendTimeout=”00:01:00″
                    bypassProxyOnLocal=”false” transactionFlow=”false” hostNameComparisonMode=”StrongWildcard”
                    maxBufferPoolSize=”2147483647″ maxReceivedMessageSize=”2147483647″
                    messageEncoding=”Text” textEncoding=”utf-8″ useDefaultWebProxy=”true”
                    allowCookies=”false”>
                    <readerQuotas maxDepth=”2147483647″ maxStringContentLength=”2147483647″ maxArrayLength=”2147483647″
                        maxBytesPerRead=”2147483647″ maxNameTableCharCount=”2147483647″ />
                    <reliableSession ordered=”true” inactivityTimeout=”00:10:00″
                        enabled=”false” />
                    <security mode=”Message”>
                        <transport clientCredentialType=”Windows” proxyCredentialType=”None”
                            realm=”" />
                        <message clientCredentialType=”Windows” negotiateServiceCredential=”true”
                            algorithmSuite=”Default” establishSecurityContext=”true” />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>

        Having done that, your service will still not using this binding configuration, you need to add the binding name to the bindingConfiguration attribute inside your service element.

  <services>
      <service behaviorConfiguration=”DataServiceBehavior” name=”Zuko.Service.DataService”>
        <endpoint address=”" binding=”wsHttpBinding” contract=”Zuko.Service.IDataService” bindingConfiguration=”WSHttpBinding_IDataService”>
          <identity>
            <dns value=”localhost” />
          </identity>
        </endpoint>
        <endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange” />
      </service>
    </services>

Older Posts »