私は第三者WSのクライアントを作成しようとしています。私のアプリケーションはJBoss AS 6(Apache CXF 2.3.1スタック)で動作しています。 wsconsume(wsdl2java)でクライアントコードを生成しました。私が得た例外をWSに接続しようとしたとき:Apache CXF - ポリシーの代替案はありません
No assertion builder for type http://schemas.microsoft.com/ws/06/2004/policy/http}BasicAuthentication registered.
Exception in thread "main" org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied.
認証WSDLの一部は次のようになります。
<wsp:Policy wsu:Id="abc_ssl_policy">
<wsp:ExactlyOne>
<wsp:All>
<http:BasicAuthentication
xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http" />
<sp:TransportBinding
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false" />
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256 />
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict />
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
クライアントコード:私はコンジットを取得しようとWHE
@WebServiceClient(name = "Abc",
wsdlLocation = "https://hiddendomain.com/abc/abc.svc?wsdl",
targetNamespace = "http://tempuri.org/")
public class Abc extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://tempuri.org/", "Abc");
public final static QName AbcSsl = new QName("http://tempuri.org/", "abc_ssl");
static {
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("user", "pas".toCharArray());
}
});
URL url = null;
try {
url = new URL("https://hiddendomain.com/abc/abc.svc?wsdl");
} catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(DistrInfo.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", "...");
}
WSDL_LOCATION = url;
}
例外がスローされます:
Client client = ClientProxy.getClient(port);
HTTPConduit con = (HTTPConduit) client.getConduit(); <- exception
I s私は非標準的なMSポリシーのためですが、私はこのポリシーを処理するために適切なIntercerptorが必要ですが、誰かが私にそれを行う方法を示すことができますか?
私はこのコードを使用したときに行って問題
おかげで、。最初はHTTPサービスを使用していましたが、HTTPSに切り替えた後、恐ろしいPolicyExceptionが発生しました。 最初はMyService ss = new MyService(新しいURL(wsdlUrl)、新しいQName( "http://tempuri.org/"、 "MyService"))を実行しました。 IMyService port = ss.getBasicHttpBindingIMyService(); '。 私は 'JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();を実行します。 factory.setServiceClass(IMyService.class); factory.setAddress(wsdlUrl.replace( "?wsdl"、 "")); IMyServiceポート=(IMyService)factory.create(); '。 – neu242
これは本当に役に立ちました!ありがとう!! –
同じ問題が発生しています....コードがTomcatで動作していましたが、jbossにコードをデプロイするときにこのエラーが発生しています。クライアントプログラムの完全なコードを共有してください。 – aravind