Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF服务在IOS中不工作_Ios_Objective C_Xcode_Web Services_Wcf - Fatal编程技术网

WCF服务在IOS中不工作

WCF服务在IOS中不工作,ios,objective-c,xcode,web-services,wcf,Ios,Objective C,Xcode,Web Services,Wcf,我正在尝试从IOS在WCF中使用登录web服务。我使用下面的代码来实现这一点。但它不起作用。谁能帮我做那件事 iSeries设备代码: namespace GimbalService { [ServiceContract] public interface IService { [OperationContract] [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json,

我正在尝试从IOS在WCF中使用登录web服务。我使用下面的代码来实现这一点。但它不起作用。谁能帮我做那件事

iSeries设备代码:

namespace GimbalService
{
[ServiceContract]
public interface IService
{
    [OperationContract]
    [WebInvoke(Method = "POST",
       ResponseFormat = WebMessageFormat.Json,
       RequestFormat = WebMessageFormat.Json,
       BodyStyle = WebMessageBodyStyle.Wrapped,
       UriTemplate = "Register"]
    string Register(string fname, string lname, string email, string password, string country);

    [OperationContract]
    [WebInvoke(Method = "GET",
        ResponseFormat = WebMessageFormat.Json,
        //RequestFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Wrapped,
        UriTemplate = "Login/{email}/{password}"]
    string Login(string email, string password);

    [OperationContract]
    string GetUserGeofence(int userId);

    [OperationContract]
    string GetUserCommunicate(int userId);

    [OperationContract]
    [WebInvoke(Method = "POST",
       ResponseFormat = WebMessageFormat.Json,
       RequestFormat = WebMessageFormat.Json,
       BodyStyle = WebMessageBodyStyle.Wrapped,
       UriTemplate = "CreateUserCommunicate"]
    string CreateUserCommunicate(int communicateId,int userId);

    [OperationContract]
    string DeleteUserGeofence(int userId,int geofenceId);

    [OperationContract]
    string DeleteUserCommunicate(int userId, int communicateId);

    [OperationContract]
    string GetUserGeofenceTypeAndLogo(int geofenceId);

}
}

服务代码是

public string Login(string email, string password)
    {
        XmlConfigurator.Configure();
        GimbalLogger.Instance.Info(String.Format("Incoming Login request: \n Email:{0}", email));
        var userAccessor = new Accessor.Accessor();
        var response = userAccessor.UserLoginAccessor(email, password);
        GimbalLogger.Instance.Info(String.Format("Login Response: {0}", response));
        GimbalLogger.Instance.Info("***********************END OF Login REQUEST***********************";
        return response;
    }
因此,在这里,我尝试使用下面的Objectice-C代码为IOS应用程序调用此Web服务

NSArray *propertyNames = [NSArray arrayWithObjects:@"username",@"password", nil];

NSArray *objects = [NSArray arrayWithObjects:txtUserName.text, txtPassword.text, nil];

NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:propertyNames];

NSData *jsonData = nil;

NSString *jsonString = nil;



NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://192.16.1.255:14/Service.svc/Login"]];

[request setValue:jsonString forHTTPHeaderField:@"json"];

[request setHTTPMethod:@"GET"];

[request setHTTPBody:jsonData];

NSError * errorReturned = nil;

NSURLResponse *theResponse =[[NSURLResponse alloc]init];

NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&theResponse error:&errorReturned];



if(errorReturned)

{

    NSLog(@"%@", errorReturned);

}

else

{

    NSString *retValue = [[NSString alloc] initWithData: data encoding:NSUTF8StringEncoding];

    NSLog(@"%@", retValue);

}
网络配置文件:

<?xml version="1.0"?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<connectionStrings>
<add name="AppConnectionString"
       connectionString="Data Source=192.36.12.56;Database=geo;uid=root;pwd=verafghdis;"
       providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
  <property name="dialect">NHibernate.Dialect.MySqlDialect</property>
  <property name="connection.provider">
    NHibernate.Connection.DriverConnectionProvider
  </property>
  <property name="connection.driver_class">
    NHibernate.Driver.MySqlDataDriver
  </property>
  <property name="connection.connection_string_name">AppConnectionString </property>
  <property name="show_sql">true</property>
  <property name="connection.release_mode">on_close</property>
  <property name="connection.isolation">ReadCommitted</property>
  <property name="command_timeout">300</property>
</session-factory>
</hibernate-configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
    <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />
</system.serviceModel>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1"/>
<customErrors mode="Off"/>
</system.web>
<log4net>
<appender name="GimbalLogFileAppender" type="log4net.Appender.RollingFileAppender">
  <param name="File" value="c:\Dev\Logs\GimbalService\GimbalServiceLog" />
  <param name="AppendToFile" value="true" />
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
  <rollingStyle value="Composite" />
  <datePattern value="&quot;_&quot;yyyyMMdd&quot;.log&quot;" />
  <maxSizeRollBackups value="10" />
  <maximumFileSize value="10MB" />
  <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mms} – %m%n" />
    <conversionPattern value="%newline%newline%date %newline%logger [%property{NDC}] %newline&gt;&gt; %message%newline" />
  </layout>
</appender>
<root>
  <level value="DEBUG" />
  <appender-ref ref="GimbalLogFileAppender" />
</root>
</log4net>

<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
    To browse web app root directory during debugging, set the value below to true.
    Set to false before deployment to avoid disclosing web app folder information.
  -->
<directoryBrowse enabled="true"/>
</system.webServer>

</configuration>

NHibernate.dialogue.mysqldialogue
NHibernate.Connection.DriverConnectionProvider
NHibernate.Driver.MySqlDataDriver
AppConnectionString
符合事实的
闭上
重新提交
300
我想打印web服务中的值。
提前感谢。

共享web.config文件请查看代码。。我已经用web配置更新了。看看上面提到的链接