2014-11-07 3 views
1

.NET WCF 서비스와 통신하는 Apache-CXF-2.7.11로 Java 클라이언트를 구성하려고합니다.서명 토큰이 없습니다. Java CXF 클라이언트

Java 클라이언트 코드가 다음과 같습니다. 클라이언트가 IDE를 통해 자동 생성되었습니다. CXF 문서에서 복사 한 자격 증명 만 있습니다.

Advertencia: Interceptor for {http://schemas.xmlsoap.org/ws/2005/02/trust/wsdl}SecurityTokenService#{http://schemas.xmlsoap.org/ws/2005/02/trust/wsdl}RequestSecurityToken has thrown exception, unwinding now 
org.apache.cxf.interceptor.Fault: No signature token 
at org.apache.cxf.ws.security.wss4j.policyhandlers.SymmetricBindingHandler.doSignBeforeEncrypt(SymmetricBindingHandler.java:398) 
at org.apache.cxf.ws.security.wss4j.policyhandlers.SymmetricBindingHandler.handleBinding(SymmetricBindingHandler.java:124) 
at org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JOutInterceptor$PolicyBasedWSS4JOutInterceptorInternal.handleMessage(PolicyBasedWSS4JOutInterceptor.java:173) 
at org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JOutInterceptor$PolicyBasedWSS4JOutInterceptorInternal.handleMessage(PolicyBasedWSS4JOutInterceptor.java:90) 
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272) 
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:570) 
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:479) 
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:382) 
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:335) 
at org.apache.cxf.ws.security.trust.AbstractSTSClient.issue(AbstractSTSClient.java:782) 
at org.apache.cxf.ws.security.trust.STSClient.requestSecurityToken(STSClient.java:62) 
at org.apache.cxf.ws.security.trust.STSClient.requestSecurityToken(STSClient.java:56) 
at org.apache.cxf.ws.security.trust.STSClient.requestSecurityToken(STSClient.java:52) 
at org.apache.cxf.ws.security.policy.interceptors.SecureConversationOutInterceptor.issueToken(SecureConversationOutInterceptor.java:167) 
at org.apache.cxf.ws.security.policy.interceptors.SecureConversationOutInterceptor.handleMessage(SecureConversationOutInterceptor.java:69) 
at org.apache.cxf.ws.security.policy.interceptors.SecureConversationOutInterceptor.handleMessage(SecureConversationOutInterceptor.java:44) 
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272) 
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:570) 
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:479) 
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:382) 
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:335) 
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) 
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135) 
at com.sun.proxy.$Proxy38.programaProveedores(Unknown Source) 
at com.wsclient.IReportes_WSHttpBindingIReportes_Client.main(IReportes_WSHttpBindingIReportes_Client.java:76) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:606) 
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) 
Caused by: org.apache.cxf.ws.policy.PolicyException: No signature token 

사용자 이름 토큰을 설정하는 다른 방법이있다 :

public static void main(String args[]) throws java.lang.Exception { 
    URL wsdlURL = Reportes.WSDL_LOCATION; 
    if (args.length > 0 && args[0] != null && !"".equals(args[0])) { 
     File wsdlFile = new File(args[0]); 
     try { 
      if (wsdlFile.exists()) { 
       wsdlURL = wsdlFile.toURI().toURL(); 
      } else { 
       wsdlURL = new URL(args[0]); 
      } 
     } catch (MalformedURLException e) { 
      e.printStackTrace(); 
     } 
    } 

    Reportes ss = new Reportes(wsdlURL, SERVICE_NAME); 
    IReportes port = ss.getWSHttpBindingIReportes(); 

    Client client = ClientProxy.getClient(port); 
    Endpoint cxfEndpoint = client.getEndpoint(); 

    Map ctx = ((BindingProvider)port).getRequestContext(); 
    ctx.put("ws-security.username", "username"); 
    ctx.put("ws-security.password", "password"); 

    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(ctx); 
    cxfEndpoint.getOutInterceptors().add(wssOut); 

    { 
    System.out.println("Invoking programaProveedores..."); 
    java.lang.String _programaProveedores_idBeneficiario = ""; 
    com.wsclient.ArrayOfProgramaProveedor _programaProveedores__return = port.programaProveedores(_programaProveedores_idBeneficiario); 
    System.out.println("programaProveedores.result=" + _programaProveedores__return); 


    } 
System.exit(0); 
} 

예외가 결과입니다? 나는이 문제를 발견했습니다

답변

1

... 내 영어에 대한

PD 미안, 난 할 노력하고있어 원래 내가 그 후, wsimport를 사용, 자바 클라이언트에서 WCF 생성 된 WSDL을 가져 오는 것입니다 나는 지하철 2.3.0를 사용하고 난 다음 오류 얻을 :

<mssp:SslContextToken 
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" xmlns:mssp="http://schemas.microsoft.com/ws/2005/07/securitypolicy"> 
    <wsp:Policy> 
    <sp:RequireDerivedKeys/> 
    </wsp:Policy> 
</mssp:SslContextToken> 

이 당신의 WCF 자체가 의미

Advertencia: SP0100: Policy assertion Assertion[com.sun.xml.ws.policy.sourcemodel.DefaultPolicyAssertionCreator$DefaultPolicyAssertion] { 
assertion data { 
    namespace = 'http://schemas.microsoft.com/ws/2005/07/securitypolicy' 
    prefix = 'mssp' 
    local name = 'SslContextToken' 
    value = 'null' 
    optional = 'false' 
    ignorable = 'false' 
    attributes { 
     name = 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy:IncludeToken', value = 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient' 
    } 
} 
no parameters 
nested policy { 
    namespace version = 'v1_5' 
    id = 'null' 
    name = 'null' 
    vocabulary { 
     1. entry = 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy:RequireDerivedKeys' 
    } 
    assertion set { 
     Assertion[com.sun.xml.ws.policy.sourcemodel.DefaultPolicyAssertionCreator$DefaultPolicyAssertion] { 
      assertion data { 
       namespace = 'http://schemas.xmlsoap.org/ws/2005/07/securitypolicy' 
       prefix = 'sp' 
       local name = 'RequireDerivedKeys' 
       value = 'null' 
       optional = 'false' 
       ignorable = 'false' 
       no attributes 
      } 
      no parameters 
      no nested policy 
     } 
    } 
} 
} is not supported under Token assertion. 

이유는 WCF WS-정책이 섹션을 contaning 것을입니다 rvice는 X.509 인증서 협상을 사용합니다. 이러한 시나리오에서 클라이언트는 서버 X.509 인증서를 암호화에 사용합니다. 여기서 유일한 점은 클라이언트가 (대부분의 경우와 같이)이 대역 외 인증을 요구받지 않고 SOAP 레벨 협상을 사용하여이 인증서를 얻는다는 것입니다. 이것은 WS-Trust에 대한 확장으로서 구현됩니다. 이것은 엄격하게 독점적 인 Microsoft 솔루션은 아니지만 Microsoft가 지금까지 구현 한 유일한 솔루션이었습니다.

<bindings> 
    <wsHttpBinding> 
     <binding> 
      <security mode="Message"> 
       <message clientCredentialType="None" negotiateServiceCredential="false" /> 
      </security> 
     </binding> 
    </wsHttpBinding> 
</bindings> 

아니면 CustomBinding에서 올바른 시나리오를 선택 : - 짧은에서 X.509 협상 (SslContextToken)이 기능을 해제하거나 귀하의 WsHttpBinding과 구성을 업데이트 .TO 상호 운용되지 않습니다

<security authenticationMode="AnonymousForCertificate"> 
    <secureConversationBootstrap /> 
</security> 

당신 또한 사용자 이름 인증에 대해 동등한 경우를 사용할 수 있습니다. 모든 클라이언트 (WCF를 포함한 클라이언트)는 이제 대역 외로 정의 된 서비스 인증서를 가져야합니다.

이 문제에 대한 참조는 http://webservices20.blogspot.mx/2008/10/interoperability-gotcha-sslcontexttoken.html

관련 문제