1

インターフェースを公開しない石鹸アクションが可能かどうか疑問に思っていました

このようにサービスインターフェースを定義します

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

「/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>
4

1 に答える 1

1

ReplyAction を設定します

[OperationContract(ReplyAction="http://Microsoft.WCF.Documentation/ResponseToOCAMethod")]
string SampleMethod(string msg);
于 2013-08-07T20:15:25.497 に答える