有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何从动态客户端web服务获取参数类型

我想从动态客户端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();
}

如何获取参数类型?(另外,我不想用parse获取参数。)

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


共 (1) 个答案

  1. # 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());
                }
    
            }