none
How do I call a WebAPi ASP.NetCore from a existing WCF application RRS feed

  • Question

  • I am needing to create a WebAPI ( may change)  middle wear application that will be consumed by several WCF applications. the challenge is that I can not change the WCF application code I do have access to it.

    I've added Restful methods in the controller and I see the call coming in as a POST. the problem is that I cannot see any of the data from the request.  I've decorated the  parameters using [fromBody]. still no success

    WCF Request :

     public System.Threading.Tasks.Task<MySvc.aResponse> fAsync(string AMethod, string ANumber, string Function, string Environment, string AString, string AInd)
            {
                MySvc.fEgcaRequest inValue = new MySvc.fequest();
                inValue.Body = new MySvc.fRequestData();
                inValue.Body.ActivationMethod = AMethod;
                inValue.Body.aNumber = ANumber;
                inValue.Body.Function = Function;
                inValue.Body.Environment = Environment;
                inValue.Body.TStr = AString;
                inValue.Body.AcctDeactPrevInd = AInd;
                return ((MySvc.caPortType)(this)).MySvc(inValue);

    WebAPI Post:

    [HttpPost]

    public Myresponse Put([FromBody] MyResponse  data)

    {

    var tempData = data;

    ...

    }

    *** the data parameter in the Put method does not contain data.


    Friday, January 6, 2017 2:22 PM

All replies

  • Hi Lawrence,

    >> the challenge is that I can not change the WCF application code I do have access to it.

    Do you mean you can’t create a new method or modify exist method in WCF application? If so, I think you could not call WebAPI from WCF application.

    If you could change code in WCF application, I suggest you try HttpClient to make request to WebAPI from WCF.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 9, 2017 1:43 AM