从Java客户端使用FSETService时出错

时间:2016-12-29 14:51:09

标签: java soap axis2

任何人都在从java开始使用California EDD FSETService。

尝试使用基于.Net的WCF服务https://fsettestprod.edd.ca.gov/FSETWCFProxyWebService/FsetService.svc?wsdl

我正在使用基本的UserNameToken身份验证和POST到https://fsettestprod.edd.ca.gov/FSETWCFProxyWebService/FsetService.svc/basic

使用Axis2 wsdl2code maven插件生成存根

错误地说

    org.apache.axis2.AxisFault: **An error occurred when verifying security for the** message.
    org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
    org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
    org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
    org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at gov.ca.edd.stub.FsetServiceStub.ping(FsetServiceStub.java:649)
    at com.preludesoftware.edd.client.Edd.initiateService(Edd.java:233)
    at com.preludesoftware.edd.client.Edd.main(Edd.java:79)

从SOAP UI使用时,相同的服务正常工作。

示例java代码:

    FsetServiceStub stub = new FsetServiceStub("https://fsettestprod.edd.ca.gov/FSETWCFProxyWebService/FsetService.svc/basic");         
    HttpTransportProperties.Authenticator basicAuthenticator = new HttpTransportProperties.Authenticator();
    List<String> authSchemes = new ArrayList<String>();
    authSchemes.add(Authenticator.BASIC);
    basicAuthenticator.setAuthSchemes(authSchemes);
    basicAuthenticator.setUsername("uName");
    basicAuthenticator.setPassword(StringEscapeUtils.unescapeHtml4("pwd"));         
    basicAuthenticator.setPreemptiveAuthentication(true);
    stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,basicAuthenticator);           
    stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,"false");           
    stub._getServiceClient().getOptions().setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
    stub.print();

任何帮助/想法都会很棒。

已编辑: 工作副本:

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(IFsetService.class);
    factory.setAddress("https://fsettestprod.edd.ca.gov/FSETWCFProxyWebService/FsetService.svc/basic"); 
    IFsetService service = (IFsetService)factory.create();
    Client client = ClientProxy.getClient(service);
    Endpoint cxfEndpoint = client.getEndpoint();
    Map<String,Object> outProps = new HashMap<String,Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.USER, "<uName>");
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
    outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,ClientPasswordCallback.class.getName());
    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    cxfEndpoint.getOutInterceptors().add(wssOut);
    String pingResponse = service.ping();

0 个答案:

没有答案