我正在使用kSoap2 v3.1从Android应用程序调用wdsl Web服务,我一直收到未找到的错误。我已经验证了URL,Soap_Action,Method_Name和命名空间都是正确的。我也一直在寻找其他原因,为什么抛出这个错误,没有其他解决方案对我有用。 webservice正在本地托管,我正在本地调试。我已经确保该服务正在使用WC FStorm和WCFTestClient,所有调用都没有任何问题。我认为我的应用程序没有任何问题,所以我已经研究了在服务中进行绑定的不同方法。
以下是webservice的App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="LocalWCF.Service1Behavior" name="LocalWCF.LocalWCF">
<endpoint address="http://localhost/LocalWCF/LocalWCF.LocalWCF.svc/" binding="basicHttpBinding" contract="LocalWCF.ILocalWCF" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/LocalWCF/LocalWCF.LocalWCF.svc/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="LocalWCF.Service1Behavior">
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="TradersWallDBEntities" connectionString="metadata=res://*/Data.TradersWallDB.csdl|res://*/Data.TradersWallDB.ssdl|res://*/Data.TradersWallDB.msl;provider=System.Data.SqlClient;provider connection string="data source=RADSTATION1000;initial catalog=TradersWallDB;persist security info=True;user id=DefaultUser;password=testpass;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
这是app中调用服务的方法
public long SendUser(User newUser)
{
final String SOAP_ACTION = "http://tempuri.org/ILocalWCF/AddUserToDB/";
final String METHOD_NAME = "AddUserToDb";
final String NAMESPACE = "http://tempuri.org/";
final String URL = "http://10.0.2.2/LocalWCF/LocalWCF.LocalWCF.svc";
final String email = newUser.email;
final String userName= newUser.userName;
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("userName", userName);
request.addProperty("email", email);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
/**
Element e = new Element();
e.setName("To");
e.setNamespace("http://schemas.xmlsoap.org/ws/2004/08/addressing");
e.addChild(Node.TEXT,URL);
Element e1 = new Element();
e1.setName("Action");
e1.setNamespace("http://schemas.xmlsoap.org/ws/2004/08/addressing");
e1.addChild(Node.TEXT,SOAP_ACTION);
envelope.headerOut = new Element[]{e,e1};
*/
HttpTransportSE transport= new HttpTransportSE(URL);
transport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
return Long.parseLong(response.toString());
} catch (Exception e) {
return -1;
}
}
任何帮助将不胜感激。我一直坚持这个并经历了一系列的修复,但这是我的最后一个小障碍。谢谢!