我想知道是否有可能让肥皂动作不暴露界面
我这样定义服务接口
[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)
{
...
}
}
网页配置
<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>
我想要“/HeartbeatResponse”或“HeartbeatResponse”
<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>