gpt4 book ai didi

web-services - 通过代理连接到 AXIS 1.4 Web 服务

转载 作者:行者123 更新时间:2023-12-04 04:42:27 27 4
gpt4 key购买 nike

我正在使用 AXIS 1.4 为我的网络服务生成 subs。这一代工作正常,但我面临着通过 WebProxy 连接到 Web 服务的问题。

我使用axistools-maven-plugin 来生成我的 Axis 类。

   <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<urls>
<url>http://mywiki/rpc/soap-axis/confluenceservice-v1?wsdl</url>
</urls>

<outputDirectory>${project.build.directory}/generated-wsdl-sources</outputDirectory>
<packageSpace>de.allianz.wsdl.confluence</packageSpace>
<testCases>false</testCases>
<serverSide>false</serverSide>
<subPackageByFileName>false</subPackageByFileName>
</configuration>
<executions>
<execution>
<id>add wsdl source</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
</dependencies>

如果我在连接之前使用以下属性 - 一切正常,但我设置了 VM 范围内的属性,这是不可取的:
 public void setProxyHost(String proxyHost) {
this.proxyHost = proxyHost;
if(proxyHost != null){
System.setProperty("http.proxyHost", proxyHost);
AxisProperties.setProperty("http.proxyHost", proxyHost);

}
}

public void setProxyPort(int proxyPort) {
this.proxyPort = proxyPort;
System.setProperty("http.proxyPort", ""+proxyPort);
AxisProperties.setProperty("http.proxyPort", ""+proxyPort);
}

有什么方法可以告诉 Axis 生成源以通过代理连接吗? (我已经阅读了有关在生成源(以访问 WSDL)时如何指定代理的信息,但这不是我所需要的 - 我需要通过代理连接到最终的 Web 服务)

我已经尝试执行以下操作:
private ConfluenceSoapService createConfluenceSoapService()
throws ServiceException {
ConfluenceSoapServiceServiceLocator csssl = new ConfluenceSoapServiceServiceLocator();
ConfluenceSoapService confluenceSoapService;
if (confluenceserviceAddress == null) {
confluenceSoapService = csssl.getConfluenceserviceV1();
} else {
URL endpoint;
try {
//endpoint = new URL(confluenceserviceAddress);
endpoint = new URL("http",proxyHost,proxyPort,confluenceserviceAddress);
} catch (java.net.MalformedURLException e) {
throw new javax.xml.rpc.ServiceException(e);
}
confluenceSoapService = csssl.getConfluenceserviceV1(endpoint);
}
ConfluenceserviceV1SoapBindingStub stub = (ConfluenceserviceV1SoapBindingStub) confluenceSoapService;
stub.setTimeout(timeout);
return confluenceSoapService;
}
并使用代理将端点更改为 URL - 但这会在运行时导致以下问题(即使代理设置已正确设置为 URL 对象。如果我使用没有代理的 URL 对象,我会遇到错误。
java.net.MalformedURLException: For input string: "8080http:"
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
我的问题:
- 我错过了什么吗?
- 有没有办法告诉 Axis 生成与网络代理一起使用的源(通过网络代理访问)

非常感谢你的帮助!如果您需要更多/其他信息来提供帮助,请告诉我。

最佳答案

试试这个,在我的情况下它有效,使用 System.setProperty 不是一个好主意,因为它设置了 VM 的值。使用 AxisProperties 将仅为特定连接设置值。我正在使用 AXIS 1.4 客户端。

AxisProperties.getProperties().put("proxySet","true");

AxisProperties.setProperty("http.proxyHost", PROXY_HOST);
AxisProperties.setProperty("http.proxyPort", PROXY_PORT);

关于web-services - 通过代理连接到 AXIS 1.4 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4277249/

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