我使用XmlSerializerFormat开发了WCF服务。当我在WCF测试客户端测试它时,我得到以下响应。
回复包含在标记<AuthenticateUserResult>
下。但是当使用客户端代理消耗服务时,我得到了包装的响应。有人可以帮助我如何避免回复包装或如何让两个回答都匹配。
WCF测试客户端响应:
<AuthenticateUserResponse xmlns="http://tempuri.org/">
<AuthenticateUserResult>
<applicationStatus>Success</applicationStatus>
<authType version="3.0">
<authenticationType xmlns="http://aaaaaaaa.xyz">0</authenticationType>
</authType>
</AuthenticateUserResult>
</AuthenticateUserResponse>
来自客户端代理的服务响应:
<AuthenticateUserResponse >
<applicationStatus xmlns="http://tempuri.org/">Success</applicationStatus>
<authType version="3.0" xmlns="http://tempuri.org/">
<authenticationType xmlns="http://aaaaaaaa.xyz">0</authenticationType>
</authType>
</AuthenticateUserResponse>
我的示例应用
服务合同:
[ServiceContract]
[XmlSerializerFormat]
public interface IService2
{
[OperationContract]
[XmlSerializerFormat]
AuthenticateUserResponse AuthenticateUser();
}
//[DataContract()]
public class AuthenticateUserResponse
{
[XmlElement("applicationStatus", IsNullable = false)]
public ApplicationStatusType ApplicationStatus
{
get;
set;
}
[XmlElement("authType")]
public AuthType AuthType
{
get;
set;
}
}
[XmlRoot(Namespace = "http://aaaaaaaa.xyz")]
public class AuthType
{
[XmlAttribute("version")]
public string Version;
[XmlElement("authenticationType")]
public int AuthenticationType
{
get;
set;
}
}
public enum ApplicationStatusType
{
Success = 0,
Failed = 0
}