Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This the function Service.svc
this works correctly when i execute it locally(run on localhost) and gives me response with value
XML
<?xml version="1.0"?>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">User exists</string>


but when deployed to IIS it only gives the follwing response with no value
XML
<?xml version="1.0"?>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"/>


Service.svc.cs

C#
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;
        }
Posted
Comments
F-ES Sitecore 2-Dec-15 6:03am    
"result" is neither 1 nor 2. It might help your debugging if you update your code

if(result==1)
{
strValue = "User exists";
}
else if(result==2)
{
strValue = "User doesn't exists";
}
else
{
strValue = "Error " + result.ToString() + " was returned";
}
Member 10528646 2-Dec-15 14:17pm    
i tried this and now it always returns error when i run it from iis but it runs fine on localhost
[no name] 2-Dec-15 6:23am    
If you are able to browse the service means it doesn't have hosting problem. Make sure that you are getting correct value in result variable. Just cross check database connection string :)
Member 10528646 2-Dec-15 14:18pm    
it works fine on localhost only shows problem when i run it in iis

1 solution

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.
 
Share this answer
 
Comments
Member 10528646 2-Dec-15 14:26pm    
i get the following error
Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.
saleemy2ks 3-Dec-15 0:52am    
You need to add a metadata exchange (mex) endpoint to your service. see the sample below, from the sample below you need to just make sure to add the end point "<endpoint address="mex" ".=""  =""
<services="">
<service name="MyService.MyService" behaviorconfiguration="metadataBehavior">
<endpoint address="http://localhost/MyService.svc" binding="customBinding" bindingconfiguration="jsonpBinding" behaviorconfiguration="MyService.MyService" contract="MyService.IMyService">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
</endpoint></endpoint></service>
</endpoint>

Let me know if this solved the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900