在使用iis时,我的WCF Web服务无法正常工作? [英] My WCF webservice is not working correctly when delpoyed to iis?

查看:63
本文介绍了在使用iis时,我的WCF Web服务无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个函数Service.svc

当我在本地执行它时(在localhost上运行)并且给我带有值的响应

This the function Service.svc
this works correctly when i execute it locally(run on localhost) and gives me response with value

<?xml version="1.0"?>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">User exists</string>





但是当部署到IIS时它只提供没有值的后续响应



but when deployed to IIS it only gives the follwing response with no value

<?xml version="1.0"?>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"/>





Service.svc.cs





Service.svc.cs

public string GetDataUsingMethod(string UEmail,string UPassword)
        {
            int result = 0;
            string strValue = "";
            Users us = new Users();
            result = us.userLogin(UEmail, UPassword);
            if(result==1)
            {
                strValue = "User exists";
            }
            else if(result==2)
            {
                strValue = "User doesn't exists";
            }
            return strValue;
        }

推荐答案

首先,我不知道你为什么要检查其他条件else if(result = = 2)。我建议如果结果== 1然后显示用户存在,那么否则不存在任何条件。确保你总是从WCF服务中返回一些值,而不是返回空字符串,这将很难进行故障排除。



我的理解显然返回的结果都不是1也就是2,所以发送空结果。



如果要调试IIS服务器上托管的WCF服务,则从WCF项目启动WCF测试客户端。启动WCF测试客户端后,转到文件菜单并说添加服务,然后提供WCF服务URL。这将为您提供从WCF服务公开的API,然后通过提供所需的输入值来选择要调试的方法。



如果您面对,请告诉我任何问题调试,都会有帮助。



如果这解决了你的问题,请告诉我。
First of all i don't know why you are checking the else condition "else if(result==2)". I suggest if result == 1 then display user exist then else does not exist without any condition. Make sure you always return some value from WCF service instead of returning empty strings which will make it difficult to troubleshoot.

What i understand is clearly the result returned is neither 1 nor 2 so it is sending the empty result.

If you want to debug the WCF service hosted on IIS server then launch the WCF Test Client from the WCF project. Once the WCF Test client is launched go to File Menu and say "Add Service" then give the WCF service URL. This will give you the API's exposed from the WCF Service and then select the method you want to debug by providing the input values required.

Please let me know if you face any issue debugging, will help.

Let me know if this solved your problem.


这篇关于在使用iis时,我的WCF Web服务无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆