4

Web サービスのサブを生成するために AXIS 1.4 を使用しています。生成はそのままで問題なく動作しますが、WebProxy 経由で Web サービスに接続する際に問題が発生しています。

axistools-maven-plugin を使用して軸クラスを生成します。

   <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);  
 }

プロキシ経由で接続するソースを生成するように軸に指示する方法はありますか? (ソースを生成するときに(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)
私の質問: - 何か足りないものはありますか? - Web プロキシで動作するソースを生成するように軸に指示する方法はありますか (Web プロキシ経由でアクセスするため)。

助けてくれてどうもありがとう!さらに詳しい情報やその他の情報が必要な場合はお知らせください。

4

1 に答える 1

5

これを試してください。私の場合はうまくいきます。VM の値を設定するため、System.setProperty を使用することはお勧めできません。AxisProperties を使用すると、特定の接続に対してのみ値が設定されます。AXIS 1.4 クライアントを使用しています。

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

    AxisProperties.setProperty("http.proxyHost", PROXY_HOST); 
    AxisProperties.setProperty("http.proxyPort", PROXY_PORT); 
于 2013-05-15T17:20:52.323 に答える