Groovy wslite:SOAP客户端异常握手失败
我正在尝试使用Groovy wslite调用SOAP服务。但我一直错误地指出PKIX路径构建失败Groovy wslite:SOAP客户端异常握手失败,groovy,soapui,Groovy,Soapui,我正在尝试使用Groovy wslite调用SOAP服务。但我一直错误地指出PKIX路径构建失败 import wslite.soap.* import wslite.http.* def client = new SOAPClient("endpointURL") client.httpClient.sslTrustStoreFile = "path to key.jks" client.httpClient.sslTrustStorePassword ="password" client.
import wslite.soap.*
import wslite.http.*
def client = new SOAPClient("endpointURL")
client.httpClient.sslTrustStoreFile = "path to key.jks"
client.httpClient.sslTrustStorePassword ="password"
client.httpClient.sslTrustAllCerts = true
def response = client.send(request)
我从SoapUI客户端以groovy脚本的形式运行代码。我能够使用相同的jks文件从SoapUI调用相同的服务,而不会出现任何问题
有人能帮我理解我错过了什么吗
堆栈跟踪
Sun Jan 17 23:46:01 PST 2016:ERROR:wslite.soap.SOAPClientException: Received fatal alert: handshake_failure
wslite.soap.SOAPClientException: Received fatal alert: handshake_failure
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:202)
at wslite.soap.SOAPClient.send(SOAPClient.groovy:64)
at wslite.soap.SOAPClient$send$0.callCurrent(Unknown Source)
at wslite.soap.SOAPClient.send(SOAPClient.groovy:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:231)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
at wslite.soap.SOAPClient.send(SOAPClient.groovy)
at wslite.soap.SOAPClient$send.call(Unknown Source)
at Script3.run(Script3.groovy:10)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:92)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.MethodMetaProperty$GetBeanMethodMetaProperty.getProperty(MethodMetaProperty.java:73)
at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:61)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
at wslite.http.HTTPClient.buildResponse(HTTPClient.groovy:152)
at wslite.http.HTTPClient.this$2$buildResponse(HTTPClient.groovy)
at wslite.http.HTTPClient$this$2$buildResponse.callCurrent(Unknown Source)
at wslite.http.HTTPClient.execute(HTTPClient.groovy:60)
at wslite.http.HTTPClient$execute.call(Unknown Source)
at wslite.soap.SOAPClient.send(SOAPClient.groovy:60)
... 18 more
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)
at java.net.URLConnection.getContentEncoding(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContentEncoding(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.MethodMetaProperty$GetBeanMethodMetaProperty.getProperty(MethodMetaProperty.java:73)
at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:61)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
at wslite.http.HTTPClient.buildResponse(HTTPClient.groovy:151)
... 23 more
虽然有点过时,但我会尽力回答你的问题。 如果将key.jks和password的路径作为变量传递,而不是以纯文本传递,则可能存在问题。 当我能够通过SoapUI发送请求并获得200个响应代码时,我或多或少遇到了相同的问题,但我的SOAPClient却不能做到这一点。 所以我检查了标题中的所有变量,发现应该用变量中的值填充的标题值只是空的。即:
String type = "text/html; charset=utf-8"
...
Content-Type: type
所以我用纯文本替换了变量
Content-Type: "text/html; charset=utf-8"
建议你也这样做虽然有点过时,我会尽力回答你的问题。 如果将key.jks和password的路径作为变量传递,而不是以纯文本传递,则可能存在问题。 当我能够通过SoapUI发送请求并获得200个响应代码时,我或多或少遇到了相同的问题,但我的SOAPClient却不能做到这一点。 所以我检查了标题中的所有变量,发现应该用变量中的值填充的标题值只是空的。即:
String type = "text/html; charset=utf-8"
...
Content-Type: type
所以我用纯文本替换了变量
Content-Type: "text/html; charset=utf-8"
建议您也这样做PKIX路径构建意味着,您的客户端正在尝试为服务器查找颁发者证书,直到找到受信任的CA证书,但这失败了。我猜,您的key.jks路径中没有所有证书。仔细检查是否使用与SoapUI相同的文件。您还应该发布整个错误堆栈。我只有一个证书,并且我已经使用keytool验证了该证书是否存在于jks文件中。堆栈跟踪现在添加到原始问题中。另外,当行“client.httpClient.sslTrustAllCerts=true”设置为false时,我收到了PKIX错误。您的意思是,服务器只使用一个自签名证书?你应该仔细检查一下。现在,
handshake\u failure
看起来您的服务器正在请求客户端身份验证,这对于不同的解决方案是不同的错误。您可以记录与-Djavax.net.debug=all
PKIX路径构建的通信,这意味着您的客户端正在尝试查找服务器的颁发者证书,直到找到受信任的CA证书为止,但此操作失败。我猜,您的key.jks路径中没有所有证书。仔细检查是否使用与SoapUI相同的文件。您还应该发布整个错误堆栈。我只有一个证书,并且我已经使用keytool验证了该证书是否存在于jks文件中。堆栈跟踪现在添加到原始问题中。另外,当行“client.httpClient.sslTrustAllCerts=true”设置为false时,我收到了PKIX错误。您的意思是,服务器只使用一个自签名证书?你应该仔细检查一下。现在,handshake\u failure
看起来您的服务器正在请求客户端身份验证,这对于不同的解决方案是不同的错误。您可以使用-Djavax.net.debug=all