Archive

Posts Tagged ‘WCF’

WCF – MSMQ based web service returns error 503

April 28th, 2009 Patrick No comments

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.

Categories: Uncategorized Tags: , ,

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

October 15th, 2008 Patrick No comments

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

Categories: Uncategorized Tags: , ,

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

July 28th, 2008 Patrick No comments

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 :)

Categories: Uncategorized Tags: ,

Passing large files over WCF channel

July 2nd, 2008 Patrick No comments

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>

Categories: Uncategorized Tags:

Microsoft Open Specification v1.0 released

July 1st, 2008 Patrick No comments

Awhile ago I blogged about Microsoft releasing products protocol documentation which are essential design specifications. That was about 2 months ago and the documents are of beta version.

Today the official version 1 is out that it covers the following products.

  1. Windows
  2. WCF
  3. Windows Server Protocol
  4. .NET Framework
  5. Office
  6. Office Binary File Format
  7. SharePoint
  8. Exchange
  9. SQL Server
  10. VBA Language Spec
  11. XAML
Categories: Uncategorized Tags: , , , , , ,

WCF Unit Test timeout issue

July 1st, 2008 Patrick No comments

image

I am creating some Unit Test for my IssueTracker project. My unit test class will connect to a WCF service and execute command. Whenever I start testing the code, after awhile the test just hang there until timeout and returns the follow message.

Failed    TestAddIssueAttachment    IssueTrackerTest    Assert.Fail failed. The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.   

I am suspecting something is not right with my code. So I start searching the web, and I came across the following post by fellow MVP Benjamin Day. He had the same issue and realized actually he forgot to close the proxy connection. Yup, WCF proxy has to be closed, refer the unit test code sample below

                        [TestMethod]
        public void TestDeleteIssueAttachment()
        {
            IssueTrackerService.IssueTrackerServiceClient client
                = new IssueTrackerService.IssueTrackerServiceClient();

            try
            {

                client.Open();

                list = client.ListIssueAttachments().ToList();

                …..

            } finally {

                 client.Close();

            }

         }

Categories: Uncategorized Tags:

VSTO Reloaded

January 17th, 2008 Patrick 3 comments

Today the MSE team did a Tech Preview to fellow developers on Visual Studio 2008 which actually available for MSDN subscribers late last year and is available for sales now.

My session is about Visual Studio Tools for Office (VSTO) 2008 and a lot of productivity enhancements have been put inside the package in this current version. They include but not limited to:

  1. Better UI Development on Office UI
    • Form Regions in Outlook
    • Custom Task Pane
    • Custom Ribbon for Excel, Word and PowerPoint.
    • No relearn, leverage on Windows Form Development skill
    • Windows Form able to host WPF app and extends this capability via Custom Task Pane
  2. SharePoint Workflow development
    • No more manual writing of workflow.xml, feature.xml (both are SharePoint feature config files) and deployment script
    • Streamline development process from 15 steps to 3 steps in VSTO 2008
  3. Word Content Control data binding with VSTO addin
    • Bringing unstructured data from Word documents to a structured world
    • Able to attach custom XML such as RosettaNet or UNeDoc which as industry based XML schema to Word data.
  4. Easy deployment of VSTO - Office Addin via Click Once
    • No more reliant on CASPOL
    • Transparent to end users

vstodemo

I demo a cool VSTO addin for Word 2007 hosting a WPF user control with colossal effect and acting as a client to a WCF services at the back end. The data access is done using LINQ for XML. After that I will publish

It is based on an article in MSDN Dec 2007 issue but the source codes there is not working for RTM version of VS 2008. Many thanks for fellow MS staff Andrew Whitechapel for making it work for VS2008 RTM.

You can download the slides and working version of the source code here. They are hosted on Windows Live Skiydrive/ Folders.

Slides in PDF

Slides in XPS

Source Code in C#

I will come out with a tutorial for the SharePoint Workflow later and also a VB9 version of the source code. So stay tuned. :)