【问题标题】:how can I get the type of the parameters from dynamic client web service如何从动态客户端 Web 服务获取参数的类型
【发布时间】:2013-12-24 13:40:07
【问题描述】:

我想从动态客户端 Web 服务中获取参数类型,但我不能。我写了这段代码:

JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf
        .createClient("http://localhost:8081/Isle/wsdl/IslemTopCarpBolCik.wsdl");

Object[] res;
try {
    res = client.invoke("toplama", 2, 3);
    System.out.println("Echo response: " + res[0]);

    Binding binding = client.getEndpoint().getBinding();
    BindingInfo bindingInfo = binding.getBindingInfo();

                 //binding.getInInterceptors();

    Collection<BindingOperationInfo> operations = bindingInfo
            .getOperations();


    for (BindingOperationInfo boi : operations) {
        OperationInfo oi = boi.getOperationInfo();
        BindingMessageInfo inputMessageInfo = boi.getInput();
        List<MessagePartInfo> parts = inputMessageInfo
                .getMessageParts();
        System.out.println("function name: "
                + oi.getName().getLocalPart());

    }
    System.out.println("binding: " + binding);

} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

如何获取参数类型? (附:我不想通过解析获取参数。)

我想知道你知道有没有定义函数来获取参数的类型?

【问题讨论】:

    标签: java web-services soap cxf soap-client


    【解决方案1】:

    这段代码对我有用..

            Binding binding = client.getEndpoint().getBinding();
            BindingInfo bindingInfo = binding.getBindingInfo();
    
            Collection<BindingOperationInfo> operations = bindingInfo
                    .getOperations();
    
            for (BindingOperationInfo boi : operations) {
                BindingMessageInfo inputMessageInfo = boi.getInput();
                List<MessagePartInfo> parts = inputMessageInfo
                        .getMessageParts();
    
                System.out.println("method name: "
                        + parts.get(0).getConcreteName().getLocalPart());
    
                for (Field param : parts.get(0).getTypeClass()
                        .getDeclaredFields()) {
                    System.out.println("param_name: " + param.getName()
                            + " type:" + param.getType());
                }
    
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多