如何在java中通过https web服务发布xml

发布于 2024-09-16 20:53:52 字数 235 浏览 4 评论 0原文

我如何将 xml 发布到 https web 服务并获取 xml 响应... 要求是这样的..

Web 服务接受参数有效负载,我们可以在其中传递 xml,并且我将获得响应 xml。

网址如下所示: https://servername/aaa/bbb/us/ws.do

how can i post xml to https web service and get the xml in response...
the requirement is this..

The web service accepts a parameter payload in which we can pass xml and i will be getting response xml.

the url looks like this:
https://servername/aaa/bbb/us/ws.do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伴梦长久 2024-09-23 20:53:52
        private static final String CERT_FILE_LOC = "/aaa/bbb/ccffdd.jks";
        System.setProperty("javax.net.ssl.trustStore", CERT_FILE_LOC);


        HostnameVerifier hv = new HostnameVerifier() {
            public boolean verify(String urlHostName, SSLSession session) {
                System.out.println("Warning: URL Host: "+urlHostName+" vs. "+session.getPeerHost());

                return true;
            }
        };

        HttpsURLConnection.setDefaultHostnameVerifier(hv);

        URL url = new URL(inputUrl);
        HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();

        connection.setDoOutput(true);

        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        String line;

        while ((line = in.readLine()) != null) {
            responseXml=responseXml+line;
            }
        in.close();
        System.out.println("responseXml");
        private static final String CERT_FILE_LOC = "/aaa/bbb/ccffdd.jks";
        System.setProperty("javax.net.ssl.trustStore", CERT_FILE_LOC);


        HostnameVerifier hv = new HostnameVerifier() {
            public boolean verify(String urlHostName, SSLSession session) {
                System.out.println("Warning: URL Host: "+urlHostName+" vs. "+session.getPeerHost());

                return true;
            }
        };

        HttpsURLConnection.setDefaultHostnameVerifier(hv);

        URL url = new URL(inputUrl);
        HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();

        connection.setDoOutput(true);

        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        String line;

        while ((line = in.readLine()) != null) {
            responseXml=responseXml+line;
            }
        in.close();
        System.out.println("responseXml");
错爱 2024-09-23 20:53:52

获取 Web 服务定义 (WSDL) 并使用 wsdl2java 客户端为 WSDL 生成 java 客户端。使用生成的客户端代码调用 Web 服务。您选择的 Web 服务框架将负责为您构建和解析 SOAP 请求/响应。示例,请参考 Apache Axis

Get the webservice definition (WSDL) and use a wsdl2java client to generate java client for the WSDL. Use the generated client code to invoke the webservice. Webservice framework that you choose will take care of constructing and parsing SOAP request/response for you. Example , refer Apache Axis

花开雨落又逢春i 2024-09-23 20:53:52

获取 Web 服务的 WSDL,并将其用于您的工具。 Eclipse Java EE 中的 Web Service Explorer 是一个不错的起点。

Get the WSDL for the web service, and use it for your tooling. A good place to start is the Web Service Explorer in Eclipse Java EE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文