Hi,
Pretty new to WCF. Till now I've simply created functions in a service which I called from silverlight. I created no formal contracts which seem the norm..
In this case I needed to pass a stream containing an image to a function in my service. I got an error telling me that functions that use streams can only have one parameter: the stream. That was unless I used a message contract. So I followed the code examples, created the message contract so I could pass in a number of parameters to my function. To make things less confusing I put the functionality to handle images into it's own service. So all we have is two functions, a messagecontract and an interface with an operation contract attribute above the functions.
To test the health of the service I viewed it in the browser and was told that
ContractDescription 'MYServerice' has zero operations; a contract must have at least one operation. After looking at MANY web posts to solve this I eventually commented out code and brought it down to it's bare essentials. I still get the "zero operations" error when I view in browser:
Here is the bare bones code with only the structural elements (this code gives an error saying that not all paths return data-I've removed the actual code but this should give you a good idea of what I've done.). Oddly if I put in a test function declaration at the top of the code (not embedded in an interface) and put operationcontract above it, the "zero operations" error goes away.
Any help would be appreciated.
using System;using System.Linq;using System.Runtime.Serialization;using System.ServiceModel;using System.ServiceModel.Activation;using System.IO;using System.Data.SqlClient;
[ServiceContract(Namespace = "")][AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class SaveImagesAsync{
[MessageContract] public class SaveToDBRequest { [MessageHeader] public Stream stream; [MessageHeader] public int ImageID; [MessageHeader] public int Pages; } [MessageContract] public class SaveToDBResponse { [MessageHeader] public String Result; } [ServiceContract] public interface ITest { [OperationContract] [TransactionFlow(TransactionFlowOption.Allowed)] SaveToDBResponse SaveToDb(SaveToDBRequest request); [OperationContract] byte[] GetPage(int pageNumber, int StartPagePosition, byte[] inputStreamArray); }
public class ImageSave : ITest { public SaveToDBResponse SaveToDb(SaveToDBRequest request) { }
public byte[] GetPage(int pageNumber, int StartPagePosition, byte[] inputStreamArray) {
}
}}
Thanks,Fig000