XFireのクライアントからの呼び出しのAxis2 Webサービス:見つからない操作のためのエンドポイント参照(EPR)
-
21-09-2019 - |
質問
私は(ユーザー名トークン)のXFireクライアントからHTTPS経由でのWS-SecurityでのAxis2 Webサービスを呼び出す必要があります。私は XFireのダイナミッククライアントを介して、運動もしませんが、WSDLベースのクライアントと運(すなわち生成することができますWSDLからJavaスタブ)。誰ポイント私を何が間違っている可能性でした(スタブ、他のWS-Securityの何か)?
例外ます:
スレッドの例外「メイン」 org.codehaus.xfire.XFireRuntimeException: できませんでしたサービス呼び出しのネスト.. 例外はあります org.codehaus.xfire.fault.XFireFault: エンドポイント・リファレンス(EPR) 操作では見られません ます。https:// localhostの/サービス/ DataServiceSample2する そしてWSAアクション= org.codehaus.xfire.fault.XFireFault: エンドポイント・リファレンス(EPR) 操作では見られません ます。https:// localhostの/サービス/ DataServiceSample2する そしてWSAアクション=
コード:
public static void main(String[] args) throws MalformedURLException {
ProtocolSocketFactory easy = new EasySSLProtocolSocketFactory();
Protocol protocol = new Protocol("https", easy, 9443);
Protocol.registerProtocol("https", protocol);
ObjectServiceFactory serviceFactory = new ObjectServiceFactory();
serviceFactory.setStyle("message");
Service serviceModel = serviceFactory.create(DataServiceSample2PortType.class);
XFireProxyFactory factory = new XFireProxyFactory();
DataServiceSample2PortType service = (DataServiceSample2PortType) factory.create(serviceModel, "https://localhost:9443/services/DataServiceSample2");
Client client = Client.getInstance(service);
client.addOutHandler(new DOMOutHandler());
Properties properties = new Properties();
properties.setProperty(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
properties.setProperty(WSHandlerConstants.USER, "admin");
properties.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
properties.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, PasswordHandler.class.getName());
client.addOutHandler(new WSS4JOutHandler(properties));
sab.TopCustomerResponse topCustomersInCalifornia = service.topCustomersInCalifornia(null);
}
解決 2
私は、HTTPヘッダーに「SOAPAction
」パラメータが欠けています。あなたにそれを直接設定することができます。
HttpsURLConnection conn;
...
conn.setRequestProperty("SOAPAction", "urn:executeXml");
私の知る限りのXFireクライアントでは、このような方法でアーカイブすることができます:
Map m = new HashMap();
m.put("SOAPAction", "urn:executeXml");
client.setProperty(CommonsHttpMessageSender.HTTP_HEADERS, m);
他のヒント
あなたのサービスが実行されているマシンのIPアドレスで、<私>はlocalhost を交換してみてください。代わりの
factory.create(serviceModel,"https://localhost:9443/services/DataServiceSample2");
あなたは、このようなIPアドレスを指定してみてくださいすることができます。
factory.create(serviceModel,"https://192.168.2.18:9443/services/DataServiceSample2");
それはあいまいなパラメータを使用してコードを出荷する悪い習慣と考えられていることをしてくださいノート。だから、それをテストした後、あなたは簡単に設定することができ、いくつかの変数にハードコードされたIPアドレスを交換する必要があります。