我无法连接到WCF服务,但它仍然会导致"启动超时已过期,放弃唤醒锁定!"这是服务文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
......
</connectionStrings>
<appSettings>
<add key="HO" value=""/>
<add key="AutoUpdatePath" value="E:AutoUpdate"/>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" maxBufferSize="2000000" maxReceivedMessageSize="2000000">
<readerQuotas maxStringContentLength="2000000" maxArrayLength="2000000" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="NewBehavior" name="XONT.Common.Data.PDAServiceBLL.MyPDAService">
<endpoint address="http://192.168.1.11:7979/mytService" binding="basicHttpBinding"
bindingConfiguration="NewBinding0" contract="My.Common.Data.PDAServiceBLL.MyPDAService"/>
<host>
<baseAddresses>
<add baseAddress="http://192.168.1.11:7979/mytService"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
我的android调用方法是这样的编辑:这里是Android调用WCF using KSOAP2
public SoapObject soap(String METHOD_NAME, String SOAP_ACTION, String NAMESPACE, String URL) throws IOException, XmlPullParserException
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); //set up request
request.addProperty("strExec", "WAT2"); //variable name, value. I got the variable name, from the wsdl file!
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //put all required data into a soap envelope
envelope.setOutputSoapObject(request); //prepare request
AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);
httpTransport.debug = true; //this is optional, use it if you don't want to use a packet sniffer to check what the sent
//message was (httpTransport.requestDump)
httpTransport.call(SOAP_ACTION, envelope); //send request
SoapObject result=(SoapObject)envelope.getResponse(); //get response
return result;
}
这是我的C#方法:
namespace My.Common.Data.PDAServiceDAL
{
public class MyPDAServiceDAL
{
EcecutiveCode = "";
sqlConnection = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
}
public List<string> loadPassword_Executive(string strExec)
{
EcecutiveCode = strExec;
sqlCon = new SqlConnection(sqlConnection);
List<string> list = new List<string>();
SqlCommand com;
SqlDataReader dr;
try
{
string sql = "select Password,BusinessUnit,PrimaryTerritoryCode,DefaultSalesWarehouse,DefaultSalesLocation from RD.Executive where ExecutiveCode = '" + strExec + "'";
com = new SqlCommand(sql, sqlCon);
sqlCon.Open();
dr = com.ExecuteReader();
if (dr.Read())
{
list.Add(dr[0].ToString());
list.Add(dr[1].ToString());
list.Add(dr[2].ToString());
list.Add(dr[3].ToString());
list.Add(dr[4].ToString());
}
}
catch (Exception e)
{
WriteToLog(e);
throw e;
}
finally
{
sqlCon.Close();
//dr.Close();
//dr.Dispose();
}
return list;
}
在活动中,我称之为:
try {
SoapObject result=soap(METHOD_NAME, SOAP_ACTION, NAMESPACE, APPURL);
Log.w("log_tag",result.getPropertyCount()+ "=====" + result.getProperty(0).toString());
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
错误为:我收到错误消息如下**启动超时已过期,放弃唤醒锁定!
**编辑:我们怎样才能增加时间?请帮我
提前感谢;
您发送的是没有任何HTTP头或正文的空POST请求。基本HTTP绑定需要有效的SOAP请求和SOAP操作,SOAP操作用于确定调用的操作。不管怎样,我认为这应该会给你一些错误,而不是超时。你能至少从你的android设备打开这个吗:http://192.168.1.11:7979/mytService?wsdl
?
手动执行所有SOAP通信相当复杂。您应该使用一些库来帮助您使用SOAP服务-请检查kSoap2。