gpt4 book ai didi

java - SOAP 请求 : Illegal Protocol https for HTTP URLConnection Factory

转载 作者:行者123 更新时间:2023-12-01 15:40:25 25 4
gpt4 key购买 nike

问题:

我正在调用 SOAP Web 服务,但需要在每次调用时更改 URL。但是,wsdl 中的端点是内部地址,因此我尝试自己编辑端点。假设这是正确的做法(?),我得到 java.io.IOException: Illegal Protocol https for HTTP URLConnection Factory 我正在努力解决。

代码:

    OtherCompanyWebService ws = new OtherCompanyWebService();
OtherCompanyWebServicePortType port = ws.getOtherCompanyWebServiceHttpSoap11Endpoint();
ServiceRequest serviceRequest = makeMyServiceRequest();

BindingProvider bindingProvider = (BindingProvider) port;
bindingProvider.getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"https://blah.blah.com/blah/services/blahWebService.blahWebServiceHttpSoap11Endpoint");

Staff staff = port.getStaffData(serviceRequest).getStaff().getValue();

堆栈跟踪:

javax.xml.ws.soap.SOAPFaultException: Could not send Message.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:199)
at $Proxy52.getStudentData(Unknown Source)
at uk.co.txttools.rm.service.RmServiceImpl.runRmJob(RmServiceImpl.java:209)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy12.runRmJob(Unknown Source)
at uk.co.txttools.rm.quartz.RmJob.execute(RmJob.java:41)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:48)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
... 16 more
Caused by: java.io.IOException: Illegal Protocol https for HTTP URLConnection Factory.
at org.apache.cxf.transport.http.HttpURLConnectionFactoryImpl.createConnection(HttpURLConnectionFactoryImpl.java:44)
at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:480)
at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:46)

最佳答案

我找到的解决方案远非理想,但似乎有效。如果您有更好的解决方案,请在此发布。

问题是在 wsdl 文件中,端点是 http。发生错误是因为我将端点更改为 https。 (这可能是一个错误?)

为了解决这个问题,我使用本地版本的 wsdl 文件,并放入两个端点,一个 http 和一个 https。然后,当我更改端点时,我要么更改 http 端点,要么更改 https 端点,具体取决于我想要 http 还是 https。

关于java - SOAP 请求 : Illegal Protocol https for HTTP URLConnection Factory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8139270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com