gpt4 book ai didi

java - 线程 "main"com.sun.xml.internal.ws.fault.ServerSOAPFaultException : Client received SOAP Fault from server 中的异常

转载 作者:行者123 更新时间:2023-11-30 08:36:13 26 4
gpt4 key购买 nike

我正在尝试学习 SOAP 协议(protocol)。因此,在使用以下命令借助 wsimport 生成 net.webservicex 代码后

C:\Program Files\Java\jdk1.8.0_74\bin>wsimport -keep -s src http://www.webservicex.net/geoipservice.asmx?WSDL

我将生成的代码放在我的项目中(请看下面的屏幕截图)。我在 run configurations --> java application --> arguments --> programm arguments--> 216.58.213.238

添加了一些 google 的 ip

但是在 IPLocationFinder 类中执行 main 方法时,出现以下错误:

IPLocationFinder 类

import net.webservicex.GeoIP;
import net.webservicex.GeoIPService;
import net.webservicex.GeoIPServiceSoap;

public class IPLocationFinder {
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("You need to pass in one IP address");
} else {
String ipAddress = args[0];
GeoIPService ipService = new GeoIPService();
GeoIPServiceSoap geoIPServiceSoap = ipService.getGeoIPServiceSoap();
// Here is line 14.
GeoIP geoIP = geoIPServiceSoap.getGeoIP(ipAddress);
System.out.println(geoIP.getCountryName());
}
}
}

错误

Exception in thread "main" com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at WebserviceX.Service.Adapter.IPAdapter.CheckIP(String IP)
at WebserviceX.Service.GeoIPService.GetGeoIP(String IPAddress)
--- End of inner exception stack trace --- Please see the server log to find more detail regarding exact cause of the failure.
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(Unknown Source)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(Unknown Source)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
at com.sun.proxy.$Proxy31.getGeoIP(Unknown Source)
at IPLocationFinder.main(IPLocationFinder.java:14)

enter image description here

enter image description here

最佳答案

Some addresses will not appear in the database and therefore cannot be mapped. This is one of the limitation of IP Address location (Geolocation).

你应该试试这个IP地址212.58.246.79

它应该显示“英国”

您可以在此处阅读有关一般地理定位的更多信息:https://www.lifewire.com/does-ip-address-geolocation-really-work-818154

希望对你有帮助。

关于java - 线程 "main"com.sun.xml.internal.ws.fault.ServerSOAPFaultException : Client received SOAP Fault from server 中的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37864395/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com