我有一个WCF服务(使用Soap而不是REST)验证用户,如果验证失败,我需要将响应作为带状态代码和状态消息的XML发送回客户端。我不确定如何在WCF中创建响应客户端的响应? 那是我的服务。
[ServiceContract]
public interface IAcqtion
{
[OperationContract]
bool Authentication(CommonLibrary.Model.AuthHeader Authentication);
[OperationContract]
string ProcessXML(CommonLibrary.Model.TransferData dto, bool Authenticated);
}
这是我正在调用此服务的测试客户端:
string rtn = "";
Service.Client client = new Service.Client();
Service.AuthHeader authentication = new Service.AuthHeader();
//Pass username and password to Authenticate Service
authentication.Username = "no";
authentication.Password = "no123";
//Pass PartnerID
authentication.partnerID = 15666;
bool auth = client.Authentication(authentication);
Service.TransferData dto = new Service.TransferData();
dto.xml = textBox1.Text;
rtn = client.ProcessXML(dto, auth);
bool auth = client.Authentication(authentication);我需要使用具有状态和代码的响应将XML返回给客户端。
解决方案可以在这里找到: 我可以将响应放回XML中。
DataContractSerializer with abstract (base) / concrete (inheriting) classes