简体   繁体   中英

.asmx Service not working when publish for some services

I have a project that needs to integrate with legacy asmx services that contains business logic that I must use. I had problems making use of the channels so were allowed to add attributes to make the services rest.

Now here is the problem, I have tested all the services with post man locally and all calls work perfectly with rest as well as the old application still working. Hosting the web app on my local IIS also works. My problem is that when I publish to the server I have some services saying that [ScriptService] attribute is not there but they are there. Then other services works. What am I missing with IIS or publishing? Here is some Name changed code sections. Had to change due to NDA

//Working Service locally returns xml
[System.Web.Services.WebService(Namespace = "http://TheService.ServiceContracts/2006/09", Name = "MyWorkingService")]
    [System.Web.Script.Services.ScriptService]
    public class MyWorkingService : IMyWorkingService
    {
        [System.ServiceModel.Web.WebInvoke(Method = "POST",
            RequestFormat = System.ServiceModel.Web.WebMessageFormat.Json,
            ResponseFormat = System.ServiceModel.Web.WebMessageFormat.Json,
            UriTemplate = "/PostMethod",
            BodyStyle = System.ServiceModel.Web.WebMessageBodyStyle.Wrapped)]
        [System.Web.Services.WebMethod]
        public string PostMethod(MyPostObjectClass item)
        {
            //Business logic
        }

    }
//Failing Service; locally returns json
    [System.Web.Services.WebService(Namespace = "http://TheService.ServiceContracts/2006/09", Name = "MyFailingService")]
    [System.Web.Script.Services.ScriptService]
    public class MyFailingService : IMyFailingService
    {
        [System.ServiceModel.Web.WebInvoke(Method = "POST",
            RequestFormat = System.ServiceModel.Web.WebMessageFormat.Json,
            ResponseFormat = System.ServiceModel.Web.WebMessageFormat.Json,
        UriTemplate = "/GetDataFromObjectFilters",
            BodyStyle = System.ServiceModel.Web.WebMessageBodyStyle.Wrapped)]
        [System.Web.Services.WebMethod]
        public MyResponseObject GetDataFromObjectFilters(ObjectFilterRequestClass item)
        {
            //Business logic
        }
    }

So I looked at my local IIS and the server IIS to try and figure out what is wrong. Matched up the handler mappings, ISAPI filters and the IIS features that is installed on my local to the server. Yet the server kept asking for the script service attribute even if it was on the class.

After a full weekend of no relax time, I ended up creating a new service project to add the services into and then started adding api controllers into the project to run alongside these services. Making use of the same name as the services to make changes less troublesome in the ui application.

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