简体   繁体   English

使用https协议消费Web服务

[英]Consume Webservice using https protocol

I want to consume a web service over https from a java client. 我想通过Java客户端通过https使用Web服务。 What steps will i need to take in order to do this? 为此,我需要采取什么步骤?

Really, there shouldn't much different from consuming a web service over HTTP. 确实,与通过HTTP使用Web服务没有太大区别。 The big thing is that the process calling the web service will have to trust the server's SSL certificate. 最重要的是,调用Web服务的进程将必须信任服务器的SSL证书。 If the certificate was purchased from a well-known certificate-issuing authority, this usually isn't a problem. 如果证书是从知名的证书颁发机构购买的,则通常不是问题。 Otherwise, the client will want to either trust the root certificate, or the certificate associated with the server's fully qualified host name. 否则,客户端将希望信任根证书,或者信任与服务器的标准主机名关联的证书。

You may need to use the keytool command to trust the server's SSL certificate. 您可能需要使用keytool命令来信任服务器的SSL证书。 I've generally found that it is necessary to run something like this: 我通常发现有必要运行以下内容:

keytool -importcert -v -trustcacerts -alias ServerName -file server_cert_file.crt -keystore client_keystore_file

Blair says it right. 布莱尔说的没错。 all the same, try it out using SoapUI , which is a web service test client. 都一样,请使用SoapUI进行尝试,SoapUI是Web服务测试客户端。 This is an open source utility : so you get a chance to see how things work under the covers. 这是一个开放源代码实用程序:这样您就有机会了解幕后的工作方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM