简体   繁体   中英

WCF service as stateless service in Service fabric

I am creating SOAP service (ASMX service) into WCF service with BasicHttpBinding. Same as implemented here

Wrote Interface as follows

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

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

Implementations of Interface:

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

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

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

After running service fabric, stateless service running properly.

I have legacy code(asmx file) where same structure was already defined and having ATPs for the same. URL where the legacy apis are exposed, I don't want to mess it. I want to expose new SOAP apis to the same URL. But, when I try to call new SOAP APIs from stateless service, it is giving me Bad request as an error. Is there any way to Create these apis into stateless service in service fabric?

It won't work just like that. SOAP entails enclosing client requests (actually their body) into an XML.

Typing the address into the browser won't create any XML, but send a plain request

So,

  1. Either you use something else to send a SOAP request (eg a WCF client , that you must write in C#, or a third-party product like SoapUI )
  2. Or you give up the SOAP requirement and use WCF to create a REST service, which won't require an XML body and can be called via browser

If you decide to go with #2, you must add this attribute in your svc file

Factory="System.ServiceModel.Activation.WebServiceHostFactory"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM