2017-08-02 195 views
1

您好我正在开发使用WCF的XML Soap服务。我的要求是更新一些数据库表。我有一个方法来更新数据库中的值。以下是我的服务。如何使用POSTMAN测试wcf soap服务?

[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; } 
} 

Missing method

下面是我的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我知道我是以下正确的方法来测试服务?如果我做错了,有人能纠正我吗?任何帮助将不胜感激。谢谢。

+0

这是不正确的 - 你不能手动构建soap请求。用一些工具为你做 –

回答

1

您必须将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> 

为了得到你应该使用服务端点定义和使用some tooling产生一个有效的请求SOAP消息的保持。

此外,您不应该将数据作为地址的一部分发送到端点地址?wsdl。它应该只是端点地址。

+0

谢谢汤姆。应该用xmlns:s =“http:// RayaSoapService /”替换xmlns:s =“http:// myNamespace /”吧? –

+0

@NiranjanGodbole这取决于你如何定义你的端点。从头开始手动破解肥皂申请是非常困难的。让一个工具为你做这件事很容易。 –

+0

好的,谢谢。当我运行应用程序时,我缺少方法名称。我可以知道我错过了什么吗?我已经附上上面的截图。 –