Click here to Skip to main content
15,567,415 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi

public interface IHealthPortalLoginService
{

[OperationContract]
[WebInvoke(UriTemplate = "/loging",Method="POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
LoginDataContract loging(LoginDataContract objlocal);

}
[DataContract]
public class LoginDataContract
{
#region Fields
[DataMember]

public int LoginId { get; set; }

[DataMember]

public string EmailAddress { get; set; }


[DataMember]

public string Password { get; set; }

[DataMember]

public int DoctorId { get; set; }

[DataMember]

public string Role { get; set; }


[DataMember]

public bool IsActive { get; set; }

[DataMember]

public DateTime CreatedDate { get; set; }

[DataMember]
public string FavoriteQuestion { get; set; }

[DataMember]
public string Answer { get; set; }

[DataMember]
public int Status { get; set; }

[DataMember]
public int LabId { get; set; }

[DataMember]
public int FrontdeskId { get; set; }

#endregion
}


Web.config


<pre lang="xml">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;configuration&gt;
&lt;appSettings&gt;
&lt;add key=&quot;DBProviderType&quot; value=&quot;1&quot;/&gt;
Password=PGI123;Pooling=true&quot;/&gt;
&lt;/appSettings&gt;
&lt;system.web&gt;
&lt;httpRuntime maxRequestLength=&quot;10000000&quot;/&gt;
&lt;compilation debug=&quot;true&quot;/&gt;
&lt;/system.web&gt;
&lt;!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. --&gt;
&lt;system.serviceModel&gt;
&lt;serviceHostingEnvironment multipleSiteBindingsEnabled=&quot;true&quot; /&gt;
&lt;services&gt;
&lt;service name=&quot;WcfContact.Service1&quot; behaviorConfiguration=&quot;httpBehaviour&quot;&gt;
&lt;endpoint address=&quot;&quot; binding=&quot;webHttpBinding&quot; contract=&quot;WcfContact.IService1&quot; behaviorConfiguration=&quot;httpEndpointBehaviour&quot; &gt;
&lt;identity&gt;
&lt;dns value=&quot;localhost&quot;/&gt;
&lt;/identity&gt;
&lt;/endpoint&gt;
&lt;endpoint address=&quot;mex&quot; binding=&quot;mexHttpBinding&quot; contract=&quot;IMetadataExchange&quot;/&gt;
&lt;/service&gt;
&lt;service name=&quot;WcfContact.HealthPortalLoginService&quot; behaviorConfiguration=&quot;httpBehaviour&quot;&gt;
&lt;endpoint address=&quot;&quot; binding=&quot;webHttpBinding&quot; contract=&quot;WcfContact.IHealthPortalLoginService&quot; behaviorConfiguration=&quot;httpEndpointBehaviour&quot;&gt;
&lt;identity&gt;
&lt;dns value=&quot;localhost&quot;/&gt;
&lt;/identity&gt;
&lt;/endpoint&gt;
&lt;endpoint address=&quot;mex&quot; binding=&quot;mexHttpBinding&quot; contract=&quot;IMetadataExchange&quot;/&gt;
&lt;/service&gt;
&lt;/services&gt;
&lt;!--&lt;bindings&gt;
&lt;webHttpBinding&gt;
&lt;binding name=&quot;StreamedRequestWebBinding&quot;
bypassProxyOnLocal=&quot;true&quot;
useDefaultWebProxy=&quot;false&quot;
hostNameComparisonMode=&quot;WeakWildcard&quot;
sendTimeout=&quot;00:05:00&quot;
openTimeout=&quot;00:05:00&quot;
receiveTimeout=&quot;00:05:00&quot;
maxReceivedMessageSize=&quot;2147483647&quot;
maxBufferSize=&quot;2147483647&quot;
maxBufferPoolSize=&quot;2147483647&quot;
transferMode=&quot;StreamedRequest&quot;&gt;
&lt;readerQuotas maxArrayLength=&quot;2147483647&quot;
maxStringContentLength=&quot;2147483647&quot;/&gt;
&lt;/binding&gt;
&lt;/webHttpBinding&gt;
&lt;/bindings&gt;--&gt;
&lt;behaviors&gt;
&lt;endpointBehaviors&gt;
&lt;!--&lt;behavior name=&quot;jsonBehavior&quot;&gt;
&lt;enableWebScript/&gt;
&lt;/behavior&gt;--&gt;
&lt;behavior name=&quot;httpEndpointBehaviour&quot;&gt;
&lt;webHttp/&gt;
&lt;/behavior&gt;
&lt;/endpointBehaviors&gt;
&lt;serviceBehaviors&gt;
&lt;behavior name=&quot;httpBehaviour&quot;&gt;
&lt;serviceMetadata httpGetEnabled=&quot;true&quot; /&gt;
&lt;serviceDebug includeExceptionDetailInFaults=&quot;false&quot; /&gt;
&lt;/behavior&gt;
&lt;behavior name=&quot;&quot;&gt;
&lt;serviceMetadata httpGetEnabled=&quot;true&quot; /&gt;
&lt;serviceDebug includeExceptionDetailInFaults=&quot;false&quot; /&gt;
&lt;/behavior&gt;
&lt;/serviceBehaviors&gt;
&lt;/behaviors&gt;
&lt;/system.serviceModel&gt;
&lt;startup&gt;
&lt;supportedRuntime version=&quot;v4.0&quot; sku=&quot;.NETFramework,Version=v4.0&quot;/&gt;
&lt;/startup&gt;
&lt;/configuration&gt;</pre>


i can consume the service from c# app


HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://xx.xx.xx.xx/ContactService/HealthPortalLoginService.svc/loging");

request.Method = "POST";
request.ContentType = @"application/json; charset=utf-8";

LoginDataContract local = new LoginDataContract();
local.EmailAddress = "satya@suryahospitals.com";
local.Password = "krishna";
local.CreatedDate = DateTime.UtcNow;


DataContractJsonSerializer jsonser = new DataContractJsonSerializer(typeof(LoginDataContract));
MemoryStream ms = new MemoryStream();
jsonser.WriteObject(ms, local);


string json = Encoding.Default.GetString(ms.ToArray());

request.ContentLength = Encoding.UTF8.GetByteCount(json.ToString());

using (Stream stream = request.GetRequestStream())
{
stream.Write(Encoding.UTF8.GetBytes(json.ToString()), 0, Encoding.UTF8.GetByteCount(json.ToString()));

}


HttpWebResponse response = request.GetResponse() as HttpWebResponse;

Stream respStream = response.GetResponseStream();
if (respStream != null)
{
//lbl.Text = new StreamReader(respStream).ReadToEnd();
LoginDataContract p2 = (LoginDataContract)jsonser.ReadObject(respStream);
}


its fine that my c# code is consuming the service
Problem is ,my ipad developer cant consume my service , is ther any problem in my code...
Posted
Updated 22-Jun-11 19:51pm
v2

1 solution

In function WCFJSON the variable varProcessData which is set to true should probably be ProcessData the global variable you defined. This is by the way bad design and should be changed. Build an object that contains these parameters and pass that configuration object to the methods that need these parameters. Better yet develop a javascript class that does what you want and stop polluting the global namespace.

Cheers!

-MRB
 
Share this answer
 
Comments
mskrishna44 16-Jun-11 8:30am    
HI There, i understand your answer, plse give me an the javascript to according to your suggestion, i am new to this env, pls help me out

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