I have the following issue: Built an email WCF service that is supposed to return to the client an array of values representing errors when the request received by the service is having problems, otherwise the service would accept the request from the client and send the email.
I did build the needed method to send the email within the service and to return an array of values, but when generating the proxy class for the client to use, I see that the method in question is still defined as void (not returning an array of values), not sure why, here is my code (below you will see some code from my service application, then some code from the generated proxy class and at the end you can see a call made to the service using the proxy calss):
public static MessageContract.ReturnValues SendEmail(MessageContract.EmailMessage emailMessage)
{
NameValueCollection mailParams = (NameValueCollection)ConfigurationManager.GetSection("Email");
MessageContract.ReturnValues errorArray = null;
errorArray = ErrorCheck.checkNow(emailMessage,mailParams);
.......
GC.Collect();
return errorArray;
}
public class EmailService : IEmailService
{
public ReturnValues SendEmail(MessageContract.EmailMessage emailMessage)
{
ReturnValues arrayOferrors = null;
try
{
arrayOferrors = AppServer.Server.SendEmail(emailMessage);
}
catch (IOException e)
{
log.Fatal("I/O exception error: " + "exception: " + e.Message + "Inner exception: " + e.InnerException + " Stack trace: " + e.StackTrace);
}
catch (Exception e)
{
log.Fatal("error detected " + "exception: " + e.Message + " Stack trace: " + e.StackTrace);
}
return arrayOferrors;
}
}
public interface IEmailService
{
[OperationContract(IsOneWay = false)]
MessageContract.ReturnValues SendEmail(MessageContract.EmailMessage emailMsg);
}
public interface IEmailService
{
[System.ServiceModel.OperationContractAttribute(Action="Host.IEmailService/IEmailService/SendEmail", ReplyAction="Host.IEmailService/IEmailService/SendEmailResponse" +
"")]
ReturnValues SendEmail(EmailMessage request);
}
public partial class ReturnValues
{
public ReturnValues()
{
}
}
public partial class EmailMessage
{
[System.ServiceModel.MessageHeaderAttribute(Namespace="Host.IEmailService")]
public DataContracts.Email EmailParamHeaders;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="Host.IEmailService", Order=0)]
public System.IO.Stream EmailAttachment;
public EmailMessage()
{
}
public EmailMessage(DataContracts.Email EmailParamHeaders, System.IO.Stream EmailAttachment)
{
this.EmailParamHeaders = EmailParamHeaders;
this.EmailAttachment = EmailAttachment;
}
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
ReturnValues IEmailService.SendEmail(EmailMessage request)
{
return base.Channel.SendEmail(request);
}
public void SendEmail(DataContracts.Email EmailParamHeaders, System.IO.Stream EmailAttachment)
{
EmailMessage inValue = new EmailMessage();
inValue.EmailParamHeaders = EmailParamHeaders;
inValue.EmailAttachment = EmailAttachment;
ReturnValues retVal = ((IEmailService)(this)).SendEmail(inValue);
}
proxy.SendEmail(emailMsg.EmailParamHeaders, result.FileByteStream);