Android:调用Web服务时出错java.net.UnknownHostException:无法解析与主机名关联的主机无地址
我正在尝试使用Soap在android中调用web服务url。但是我犯了个错误Android:调用Web服务时出错java.net.UnknownHostException:无法解析与主机名关联的主机无地址,android,Android,我正在尝试使用Soap在android中调用web服务url。但是我犯了个错误 "java.net.UnknownHostException: Unable to resolve host "manvswsc00": No address associated with hostname" . 我已在AndroidManifest文件中添加了internet权限。有人能帮我解决这个问题吗 在MyActivity.java中,我创建了一个Activity,它使用异步Taski.e调用we
"java.net.UnknownHostException: Unable to resolve host "manvswsc00": No address associated with hostname" .
我已在AndroidManifest文件中添加了internet权限。有人能帮我解决这个问题吗
在MyActivity.java中,我创建了一个Activity,它使用异步Taski.e调用web服务Url。在后台
在Soap.java中,用于使用Soap调用webservice Url
请检查一下webservice url,我在选择名称空间、url、方法、SOAP\U操作时是否做错了什么
日志:
MyActivity.java
AndroidManifest.xml
`在这里输入代码`
网络服务:
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:scns="http://webservices.bankfusion.trapedza.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsns="http://CreateAccount" name="CreateAccountService" targetNamespace="http://CreateAccount">
<wsdl:types>
<xsd:schema xmlns="http://webservices.bankfusion.trapedza.com" xmlns:bf="http://www.misys.com/bankfusion/attributes" xmlns:ct0="http://www.misys.com/cbs/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://webservices.bankfusion.trapedza.com">
<xsd:import namespace="http://www.misys.com/bankfusion/attributes" schemaLocation="http://10.117.208.174:9085/bfweb/servlet/XSDServlet?resourceID=bf/com/misys/bankfusion/attributes/BFHeader"/>
<xsd:import namespace="http://www.misys.com/cbs/types" schemaLocation="http://10.117.208.174:9085/bfweb/servlet/XSDServlet?resourceID=bf/com/misys/cbs/types/CreateAccountRq"/>
<xsd:element name="bfgenericsoapheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" ref="authentication"/>
<xsd:element name="BFHeader" type="bf:BFHeader"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:group name="authgroup">
<xsd:sequence>
<xsd:element name="userName" type="xsd:string"/>
<xsd:element name="password" type="xsd:string"/>
</xsd:sequence>
</xsd:group>
<xsd:element name="authentication">
<xsd:complexType>
<xsd:sequence>
<xsd:group ref="authgroup"/>
<xsd:element minOccurs="0" ref="passCode"/>
<xsd:element minOccurs="0" ref="userLocator"/>
<xsd:element minOccurs="0" ref="casRestletUrl"/>
<xsd:element minOccurs="0" ref="casValidateUrl"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="password" type="xsd:string"/>
<xsd:element name="userLocator" type="xsd:string"/>
<xsd:element name="userName" type="xsd:string"/>
<xsd:element name="passCode" type="xsd:string"/>
<xsd:element name="casRestletUrl" type="xsd:string"/>
<xsd:element name="casValidateUrl" type="xsd:string"/>
<xsd:element name="CB_ACC_CreateAccount_SRV" type="scns:CB_ACC_CreateAccount_SRVType"/>
<xsd:complexType name="CB_ACC_CreateAccount_SRVType">
<xsd:sequence>
<xsd:element name="createAccountRq" type="ct0:createAccountRq"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="CB_ACC_CreateAccount_SRVResponse" type="scns:CB_ACC_CreateAccount_SRVResponseType"/>
<xsd:complexType name="CB_ACC_CreateAccount_SRVResponseType">
<xsd:sequence>
<xsd:element name="createAccountRs" type="ct0:createAccountRs"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="bfgenericsoapheader">
<wsdl:part name="bfgenericsoapheader" element="scns:bfgenericsoapheader"></wsdl:part>
</wsdl:message>
<wsdl:message name="CB_ACC_CreateAccount_SRVResponse">
<wsdl:part name="CB_ACC_CreateAccount_SRVResponse" element="scns:CB_ACC_CreateAccount_SRVResponse"></wsdl:part>
</wsdl:message>
<wsdl:message name="CB_ACC_CreateAccount_SRVRequest">
<wsdl:part name="CB_ACC_CreateAccount_SRVRequest" element="scns:CB_ACC_CreateAccount_SRV"></wsdl:part>
</wsdl:message>
<wsdl:portType name="CreateAccountPortType">
<wsdl:operation name="CB_ACC_CreateAccount_SRV">
<wsdl:input message="wsns:CB_ACC_CreateAccount_SRVRequest"></wsdl:input>
<wsdl:output message="wsns:CB_ACC_CreateAccount_SRVResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CreateAccountSoapBinding" type="wsns:CreateAccountPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="CB_ACC_CreateAccount_SRV">
<soap:operation soapAction="http://CreateAccount/CreateAccountPortType/CB_ACC_CreateAccount_SRVRequest"/>
<wsdl:input>
<soap:body parts="CB_ACC_CreateAccount_SRVRequest" use="literal"/>
<soap:header message="wsns:bfgenericsoapheader" part="bfgenericsoapheader" use="literal"></soap:header>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CreateAccountService">
<wsdl:port name="CreateAccountPort" binding="wsns:CreateAccountSoapBinding">
<soap:address location="http://10.117.208.174:9085/bfweb/services/CreateAccount"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
您正在使用
字符串URL=”执行rest服务http://manvswsc00:9085/bfweb/services/CreateAccount?wsdl";代码>此url
您必须将服务器名称manvswsc00:9085
更改为该服务器的IP地址
供参考检查
它会解决您的问题。我认为您的服务是在本地主机上实现的。因此,当您尝试在设备上连接到它时。您的设备找不到您的Web服务。您可以尝试使用浏览器打开您的服务。错误“缺少验证元素”与此银行平台验证每个请求的方式有关。它们要求您在标题“authentication”元素中发送“userName”和“password”。这将解决这个问题。
ie:{身份验证:{用户名:'xxx´,密码:'xxx´}
如果发送纯xml,请填写标题 将manvswsc00:9085
替换为Soap.java
中服务器的ip地址。。。检查此项,我已将Url从manvswsc00更改为IP地址。现在,我又犯了一个错误。现在我得到了另一个错误:SoapFault-faultcode:'soapenv:Server'faultstring:'Missing authentication element'faultactor:'null'详细信息:org.kxml2.kdom。Node@b0687d4 . 可以检查一下我是否使用了正确的SOAPACTION、命名空间和方法名。请让我知道我已将Url从manvswsc00更改为IP地址。现在,我又犯了一个错误。现在我得到了另一个错误:SoapFault-faultcode:'soapenv:Server'faultstring:'Missing authentication element'faultactor:'null'详细信息:org.kxml2.kdom。Node@b0687d4 . 可以检查一下我是否使用了正确的SOAPACTION、命名空间和方法名。请让我知道我已将Url从manvswsc00更改为IP地址。现在,我又犯了一个错误。现在我得到了另一个错误:SoapFault-faultcode:'soapenv:Server'faultstring:'Missing authentication element'faultactor:'null'详细信息:org.kxml2.kdom。Node@b0687d4 . 可以检查一下我是否使用了正确的SOAPACTION、命名空间和方法名。请让我知道
package com.example.myapp;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class MyActivity extends Activity {
TextView txt;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txt = (TextView) findViewById(R.id.textView);
new AsyncCallSoap().execute();
}
public class AsyncCallSoap extends AsyncTask<String, Void, String>
{
private final ProgressDialog dialog = new ProgressDialog(getApplicationContext());
protected String doInBackground(String... params) {
Soap CS = new Soap();
String response = CS.GetResponse();
Log.d("MyApp", "response:" + response);
return response;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
dialog.dismiss();
txt.setText(result);
}
}
}
package com.example.myapp;
import android.util.Log;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
public class Soap {
private String resp;
public String GetResponse() {
String URL = "http://manvswsc00:9085/bfweb/services/CreateAccount?wsdl";
String NAMESPACE = "http://CreateAccount";
String SOAP_ACTION_PREFIX = "/";
String METHOD = "CB_ACC_CreateAccount_SRV";
String SOAP_ACTION = " http://CreateAccount/CreateAccountPortType/CB_ACC_CreateAccount_SRVRequest";
SoapObject request = new SoapObject(NAMESPACE, METHOD);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
try {
HttpTransportSE transport = new HttpTransportSE(URL);
transport.debug=true;
transport.call(SOAP_ACTION, envelope);
resp = envelope.getResponse().toString();
Log.d("MyApp", "Response :" + resp);
} catch (Exception e) {
Log.d("MyApp","Exception");
e.printStackTrace();
resp = e.getMessage();
}
return resp;
}`enter code here`
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10"/>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<activity android:name="MyActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>`enter code here`
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:scns="http://webservices.bankfusion.trapedza.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsns="http://CreateAccount" name="CreateAccountService" targetNamespace="http://CreateAccount">
<wsdl:types>
<xsd:schema xmlns="http://webservices.bankfusion.trapedza.com" xmlns:bf="http://www.misys.com/bankfusion/attributes" xmlns:ct0="http://www.misys.com/cbs/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://webservices.bankfusion.trapedza.com">
<xsd:import namespace="http://www.misys.com/bankfusion/attributes" schemaLocation="http://10.117.208.174:9085/bfweb/servlet/XSDServlet?resourceID=bf/com/misys/bankfusion/attributes/BFHeader"/>
<xsd:import namespace="http://www.misys.com/cbs/types" schemaLocation="http://10.117.208.174:9085/bfweb/servlet/XSDServlet?resourceID=bf/com/misys/cbs/types/CreateAccountRq"/>
<xsd:element name="bfgenericsoapheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" ref="authentication"/>
<xsd:element name="BFHeader" type="bf:BFHeader"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:group name="authgroup">
<xsd:sequence>
<xsd:element name="userName" type="xsd:string"/>
<xsd:element name="password" type="xsd:string"/>
</xsd:sequence>
</xsd:group>
<xsd:element name="authentication">
<xsd:complexType>
<xsd:sequence>
<xsd:group ref="authgroup"/>
<xsd:element minOccurs="0" ref="passCode"/>
<xsd:element minOccurs="0" ref="userLocator"/>
<xsd:element minOccurs="0" ref="casRestletUrl"/>
<xsd:element minOccurs="0" ref="casValidateUrl"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="password" type="xsd:string"/>
<xsd:element name="userLocator" type="xsd:string"/>
<xsd:element name="userName" type="xsd:string"/>
<xsd:element name="passCode" type="xsd:string"/>
<xsd:element name="casRestletUrl" type="xsd:string"/>
<xsd:element name="casValidateUrl" type="xsd:string"/>
<xsd:element name="CB_ACC_CreateAccount_SRV" type="scns:CB_ACC_CreateAccount_SRVType"/>
<xsd:complexType name="CB_ACC_CreateAccount_SRVType">
<xsd:sequence>
<xsd:element name="createAccountRq" type="ct0:createAccountRq"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="CB_ACC_CreateAccount_SRVResponse" type="scns:CB_ACC_CreateAccount_SRVResponseType"/>
<xsd:complexType name="CB_ACC_CreateAccount_SRVResponseType">
<xsd:sequence>
<xsd:element name="createAccountRs" type="ct0:createAccountRs"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="bfgenericsoapheader">
<wsdl:part name="bfgenericsoapheader" element="scns:bfgenericsoapheader"></wsdl:part>
</wsdl:message>
<wsdl:message name="CB_ACC_CreateAccount_SRVResponse">
<wsdl:part name="CB_ACC_CreateAccount_SRVResponse" element="scns:CB_ACC_CreateAccount_SRVResponse"></wsdl:part>
</wsdl:message>
<wsdl:message name="CB_ACC_CreateAccount_SRVRequest">
<wsdl:part name="CB_ACC_CreateAccount_SRVRequest" element="scns:CB_ACC_CreateAccount_SRV"></wsdl:part>
</wsdl:message>
<wsdl:portType name="CreateAccountPortType">
<wsdl:operation name="CB_ACC_CreateAccount_SRV">
<wsdl:input message="wsns:CB_ACC_CreateAccount_SRVRequest"></wsdl:input>
<wsdl:output message="wsns:CB_ACC_CreateAccount_SRVResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CreateAccountSoapBinding" type="wsns:CreateAccountPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="CB_ACC_CreateAccount_SRV">
<soap:operation soapAction="http://CreateAccount/CreateAccountPortType/CB_ACC_CreateAccount_SRVRequest"/>
<wsdl:input>
<soap:body parts="CB_ACC_CreateAccount_SRVRequest" use="literal"/>
<soap:header message="wsns:bfgenericsoapheader" part="bfgenericsoapheader" use="literal"></soap:header>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CreateAccountService">
<wsdl:port name="CreateAccountPort" binding="wsns:CreateAccountSoapBinding">
<soap:address location="http://10.117.208.174:9085/bfweb/services/CreateAccount"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>