WCF服务作为Service Fabric中的无状态服务

时间:2017-10-27 14:34:05

标签: c# web-services wcf soap azure-service-fabric

我使用BasicHttpBinding创建SOAP服务(ASMX服务)到WCF服务。与已实施的here

相同

按如下方式写入界面

[ServiceContract]
public interface IExample
    {
    [OperationContract]
    [WebMethod]
    Task<XmlElement> GetDetails ();

    [OperationContract]
    [WebInvoke(Method = "Get", UriTemplate = "/GetExample")]
    Task<string> GetExample (string guid);
    }

接口的实现:

        public class ImplementInteface: IExample{
        public ImplementInterface(){}

        public Task<XmleElement> GetDetails(){
            //Implementation of GetDetails function
        }

        public Task<string> GetExample(string guid){
            //Implementation of GetExampl function
        }
    }

运行service fabric后,无状态服务正常运行。

我有遗留代码(asmx文件),其中已经定义了相同的结构并且具有相同的ATP。遗留api暴露的URL,我不想弄乱它。 我想将新的SOAP apis暴露给同一个URL。 但是,当我尝试从无状态服务调用新的SOAP API时,它会将错误请求作为错误提供给我。 有没有办法在服务结构中将这些apis创建为无状态服务?

1 个答案:

答案 0 :(得分:0)

它不会像那样工作。 SOAP 需要将客户端请求(实际上是它们的主体)封装到XML中。

在浏览器中键入地址不会创建任何XML,但会发送普通请求

所以,

  1. 您使用其他内容发送SOAP请求(例如 WCF客户端,您必须使用C#编写,或者第三方产品,例如 SoapUI )< / LI>
  2. 或者您放弃SOAP要求并使用WCF创建 REST 服务,该服务不需要XML主体并且可以通过浏览器调用
  3. 如果您决定使用#2,则必须在svc文件中添加此属性

    Factory="System.ServiceModel.Activation.WebServiceHostFactory"
    
相关问题