0
私は石鹸のweserviceの例を試していました。 このコードでは、GeoIp Webサービスを使用してIPアドレスから国を特定しています。 コードを実行しているときに、以下の例外が発生しています。オブジェクト参照がコード実行中にオブジェクトのインスタンスに設定されていない
例外:
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(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:116)
at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:238)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:189)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:276)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:104)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147)
at com.sun.proxy.$Proxy31.getGeoIP(Unknown Source)
at org.manjosh.demo.IPlocationFinder.main(IPlocationFinder.java:19)
マイコード:
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 atleast 1 IP address");
}
else
{
String ipAddress = args[0];
GeoIPService ipService = new GeoIPService();
GeoIPServiceSoap geoIpserviceSoap = ipService.getGeoIPServiceSoap();
GeoIP geoIp = geoIpserviceSoap.getGeoIP(ipAddress);
System.out.println((String)geoIp.getCountryName());
}
}
}
このIP 212.58.246.79を試して、あなたが英国を取得しているかどうかを確認してください。これを行うと、入力したIPをマップできないことを意味します。多くの人が行方不明になっているため、貧しいサービスです。 何千ものIPを持つ無料のデータベースがあります。そのうちの1つを見つけ、Webサービスに頼るのではなく、自分のMySQLで検索します。 – Arminius
例外は何が起こったかを示します。あなたはホストに到着した、あなたの要求を送ったが、それはサービスのために良くない、またはそれの中に何か間違っている。あなたが送信したものと実際の石鹸の欠陥は何かをさらに把握する必要があります。 SOAPUIとtcpMonitorを使用してみてください。 SOAPUIを動作させると、コード要求とSOAPUI要求を比較できます。 – Vadim
ありがとう、それは英国のために働く。 – manjosh