网站上的小动画咋做/友情链接网自动收录
我在使用SOAP 1.1消息的Web服务中遇到了客户端所需格式的问题,这正是他所期望的:
这就是我现在所拥有的
这就是我的实施方式
[WebService(Namespace = "http://www.mycompany.com/service")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class MyService : System.Web.Services.WebService
{
[WebMethod]
public PingResponse PingRequest([XmlAttribute] string Token)
{
//do stuffs
if (success) {
return new PingResponse { Token = Token, Status = "Success" };
}
else {
return new PingResponse { Token = Token, Status = "Failed", Error = new Error { Code = "NoConnection", Message = "Can't reach the server" } };
}
}
}
[XmlRoot(ElementName = "PingResponse", Namespace = "http://www.mycompany.com/service")]
public class PingResponse
{
[XmlNamespaceDeclarations]
public XmlSerializerNamespaces xmlns = new XmlSerializerNamespaces();
[XmlAttribute]
public string Token { get; set; }
[XmlAttribute]
public string Status { get; set; }
[XmlElement(ElementName = "Error", Namespace = "http://www.mycompany.com/service")]
public Error Error { get; set; }
public PingResponse()
{
xmlns.Add("m", "http://www.mycompany.com/service");
}
}
[DataContract(Namespace = "http://www.mycompany.com/service")]
public class Error
{
[XmlAttribute]
public string Code { get; set; }
[XmlAttribute]
public string Message { get; set; }
}
因此,您可以在我的响应中看到一个名为 PingRequestResponse 的aditional Xml元素,由WebService使用MethodNameResponse格式生成,之前我还有另一个名为 PingRequestResult 的元素,位于PingRequestResponse下面,但我能够在 class 中使用 [XmlRoot(ElementName = "PingResponse", 删除它
所以我需要做下一个:
删除PingRequestResponse元素并将PingResponse直接放在正文下方
将SOAP消息(信封和正文)的名称空间更改为"SOAP-ENV"
从SOAP消息中删除xsi和xsd
任何帮助将不胜感激,谢谢 .
EDIT:
到目前为止,我还没有WSDL,所以现在这不是一个选择