Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在不公开服务接口的情况下指定自定义SoapAction_C#_Asp.net_Wcf_Soap - Fatal编程技术网

C# 如何在不公开服务接口的情况下指定自定义SoapAction

C# 如何在不公开服务接口的情况下指定自定义SoapAction,c#,asp.net,wcf,soap,C#,Asp.net,Wcf,Soap,我想知道是否有可能让soap操作不公开接口 我这样定义服务接口 [ServiceContract(Namespace = "/")] public interface IService { [OperationContract(Action = "Heartbeat", Name = "Heartbeat")] [XmlSerializerFormat] [WebInvoke(RequestFormat = WebMessageFormat.Xml, ResponseFo

我想知道是否有可能让soap操作不公开接口

我这样定义服务接口

[ServiceContract(Namespace = "/")]
public interface IService
{
    [OperationContract(Action = "Heartbeat", Name = "Heartbeat")]
    [XmlSerializerFormat]
    [WebInvoke(RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/Heartbeat")]
    HeartbeatResponse Heartbeat(HeartbeatRequest request);
}
实施:

[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any, Namespace = "/")]
public class Service : IService
{
    public HeartbeatResponse Heartbeat(HeartbeatRequest request)
    {
        ...
    }
}
Web.config

<behavior name="EndpointBehavior">
  <serviceMetadata httpGetEnabled="true" />
  <serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<bindings>
  <wsHttpBinding>
    <binding name="SOAP12">
      <security mode="None">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<service behaviorConfiguration="EndpointBehavior" name="xxxxxx.Service">
    <endpoint binding="wsHttpBinding" bindingConfiguration="SOAP12" name="Service" bindingNamespace="/" contract="xxxxxx.IService" />
</service>

以下是我得到的答复:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
   <s:Header>
      <a:Action s:mustUnderstand="1">/IService/HeartbeatResponse</a:Action>
   </s:Header>
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <heartbeatResponse xmlns="urn://Ocpp/Cs/2012/06/">
         <currentTime>2013-08-07T19:59:38.5842774Z</currentTime>
      </heartbeatResponse>
   </s:Body>
</s:Envelope>

/iSeries设备/心跳响应
2013-08-07T19:59:38.5842774Z
我想要“/HeartbeatResponse”或“HeartbeatResponse”


/令人心碎的反应
2013-08-07T19:35:57.9349568Z

:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
   <s:Header>
      <a:Action s:mustUnderstand="1">/HeartbeatResponse</a:Action>
   </s:Header>
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <heartbeatResponse xmlns="urn://Ocpp/Cs/2012/06/">
         <currentTime>2013-08-07T19:35:57.9349568Z</currentTime>
      </heartbeatResponse>
   </s:Body>
</s:Envelope>
[OperationContract(ReplyAction="http://Microsoft.WCF.Documentation/ResponseToOCAMethod")]
string SampleMethod(string msg);