嗨,我正在使用WCF开发XML Soap服务。我的需求是更新一些数据库表。我有一个方法可以更新db中的值。下面是我的服务。
[ServiceContract]
public interface IOpportunity
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Xml, UriTemplate = "postmethod/updateOpportunity")]
bool updateOpportunity(opportunityActivity obj);
}
[DataContract]
public class opportunityActivity
{
[DataMember]
public string opportunityID { get; set; }
[DataMember]
public string opportunityStatus { get; set; }
[DataMember]
public string opportunityserviceType { get; set; }
}
下面是我的xml。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://localhost:39512/Opportunity.svc">
<soapenv:Header/>
<soapenv:Body>
<s:request>
<opportunityID>1-1D5SJX</opportunityID>
<opportunityStatus>Completed</opportunityStatus>
<opportunityserviceType>LEASE_REQUEST</opportunityserviceType>
</s:request>
</soapenv:Body>
</soapenv:Envelope>
当我如上所示尝试时,我得到了400个错误的请求error.May,我知道我是否遵循了正确的方法来测试服务?如果我做错了,有人能纠正我吗?任何帮助都将不胜感激。谢谢。
发布于 2017-08-02 17:42:10
您必须将soap消息传递给服务端点。
例如
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://myNamespace/">
<soapenv:Header/>
<soapenv:Body>
<s:request>
....
</s:request>
</soapenv:Body>
</soapenv:Envelope>
要获得soap消息,您应该使用服务端点定义并使用some tooling来生成有效的请求。
此外,不应将?wsdl
作为地址的一部分向端点地址发送数据。它应该只是端点地址。
https://stackoverflow.com/questions/45456588
复制相似问题