惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Blog — PlanetScale
Blog — PlanetScale
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
L
LangChain Blog
F
Fortinet All Blogs
C
Check Point Blog
Google DeepMind News
Google DeepMind News
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
J
Java Code Geeks
月光博客
月光博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
宝玉的分享
宝玉的分享
Jina AI
Jina AI

博客园 - blueKnight

【转】HttpClient使用Post和Get提交参数 Java解析Soap XML HttpClient示例 【转】C++标准库和标准模板库 dotNetFrameWork 3.5SP1离线安装 笔记本电脑win7创建WIFI热点 【转】Oracle免客户端For .Net(增加分析Devart和DataDirect) 【转】ORA-00257 archiver error. 错误的处理方法 数学表达式与二叉树 FIREFOX不支持font-family: webdings;怎么办? "5","6"排序上下箭头问题 【转】Eclipse插件开发之基础篇(1) 插件开发的基础知识 http MIME大全 在iframe里的页面编写js,实现在父窗口上创建动画效果展开和收缩的div(不变动iframe父窗口代码) FreeMarker示例 转:用XML编写EXCEL文件 【网摘】BI系统(Business Intelligence) js获取周.html 关于j2ee工程发布到was上后,部分更新,例修改web.xml配置文件不起作用的原因解析 SSI(Struts2+Spring2+IBatis)代码生成器(纯Java版)
Java根据WSDL生成request的SOAP报文模板
blueKnight · 2020-04-26 · via 博客园 - blueKnight
import groovy.xml.MarkupBuilder;
import org.junit.Test;
import com.predic8.wsdl.*;
import com.predic8.wstool.creator.RequestTemplateCreator;
import com.predic8.wstool.creator.SOARequestCreator;

    @Test
    public void testCreateSOAP() throws IOException {
        String wsdlUrl = "http://localhost:19092/financial-budget-ws/budgetHold?wsdl";
        WSDLParser parser = new WSDLParser();
        Definitions wsdl = parser.parse(wsdlUrl);
        StringWriter writer = new StringWriter();
        SOARequestCreator creator = new SOARequestCreator(wsdl, new RequestTemplateCreator(), new MarkupBuilder(writer));
//        creator.setBuilder(new MarkupBuilder(writer));
//        creator.setDefinitions(wsdl);
//        creator.setCreator(new RequestTemplateCreator());

/*        // 针对new RequestCreator()可以赋值参数
        creator.setCreator(new RequestCreator());
        HashMap<String, String> formParams = new HashMap<String, String>();
        formParams.put("xpath:/BudgetHold/BudgetHoldRequest/SEQ_NO", "202004260001");
        formParams.put("xpath:/BudgetHold/BudgetHoldRequest/INTF_BILL_NO", "20200001");
        creator.setFormParams(formParams);*/

        for (Service service : wsdl.getServices()) {
            for (Port port : service.getPorts()) {
                Binding binding = port.getBinding();
                PortType portType = binding.getPortType();
                for (Operation op : portType.getOperations()) {
                    System.out.println(op.getName() + " -- " + op.getInput().getName() + " -- " + op.getOutput().getMessage().getName());

                    creator.createRequest(port.getName(), op.getName(), binding.getName());
                    System.out.println(writer);
                    writer.getBuffer().setLength(0);
                }
            }
        }

//        <dependency>
//            <groupId>com.predic8</groupId>
//            <artifactId>soa-model-core</artifactId>
//        </dependency>
    }

posted @ 2020-04-26 16:01  blueKnight  Views(4565)  Comments()    收藏  举报