I've created a fairly simply web service that has 1 method: UploadFile. Obviously, it works on my machine ©. However, once I upload it, the method return status 202 (Accepted). However, the file never arrives there and there are no errors that I can see. I开发者_开发技巧've added logging to pretty much every second like of code, but it does not seem like the method actually executes.
How do I debug something like that?
Here is my server-side code for reference:
[ServiceContract]
interface IUploaderService
{
[OperationContract(IsOneWay = true)]
[WebInvoke(Method = "POST", UriTemplate = "/UploadFile?fileName={fileName}")]
void UploadFile(string fileName, Stream fileContents);
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class UploaderService : IUploaderService //ServiceHostFactory
{
public void UploadFile(string fileName, Stream fileContents)
{
Log.Add("In UploadFile");
}
}
You have an interesting problem, and I played around with it and wrote a solution in the post at http://blogs.msdn.com/b/carlosfigueira/archive/2011/08/02/wcf-extensibility-system-diagnostic-tracing.aspx.
Basically, instead of tracing to a file (which is the usual way of doing tracing), you'd add a custom trace listener which would collect the traces from your application. You can use one of the databases provided by GoDaddy (MySql, SqlServer, EasyDB), or like in the code sample linked in the post, store the traces in memory and expose them via another WCF service.
try following
[ServiceContract]
interface IUploaderService
{
[OperationContract(IsOneWay = true)]
[WebInvoke(Method = "POST", UriTemplate = "/UploadFile?fileName={fileName}")]
[WebContentType("application/octet-stream")]
void UploadFile(string fileName, Stream fileContents);
}
If it doesn't work I would also try
[OperationContract]
this way if something happens on service you will have feedback on client side.
精彩评论