axis2 调用webservice
生活随笔
收集整理的這篇文章主要介紹了
axis2 调用webservice
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
maven配置:主要引用包及plugins
<properties><axis2.version>1.6.1</axis2.version></properties><dependencies><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-kernel</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-adb</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-transport-http</artifactId><version>${axis2.version}</version></dependency><dependency><groupId>org.apache.axis2</groupId><artifactId>axis2-transport-local</artifactId><version>${axis2.version}</version></dependency></dependencies><build><plugins><plugin><groupId>org.apache.axis2</groupId><artifactId>axis2-wsdl2code-maven-plugin</artifactId><version>1.6.1</version><executions><execution><id>wsdl2code-client</id><phase>generate-sources</phase><goals><goal>wsdl2code</goal></goals></execution></executions><configuration><wsdlFile>src/main/resources/wsdl/IXman.wsdl</wsdlFile><packageName>com.stub.generated</packageName><generateServicesXml>false</generateServicesXml><unpackClasses>true</unpackClasses></configuration></plugin></plugins></build>通過wsdlFile屬性指定wsdl所在文件。
如果是有多個wsdl需要生成java代碼,則可以用下面的配置:
<plugin><groupId>org.apache.axis2</groupId><artifactId>axis2-wsdl2code-maven-plugin</artifactId><version>1.6.0</version><executions><execution><id>ws1</id><goals><goal>wsdl2code</goal></goals><configuration><unpackClasses>true</unpackClasses><databindingName>adb</databindingName><packageName>org.example.stackoverflow.axis2-maven</packageName><wsdlFile>src/main/resources/service1.wsdl</wsdlFile><outputDirectory>target/generated-sources</outputDirectory><syncMode>sync</syncMode></configuration></execution><execution><id>ws2</id><goals><goal>wsdl2code</goal></goals><configuration><unpackClasses>true</unpackClasses><databindingName>adb</databindingName><packageName>org.example.stackoverflow.axis2-maven</packageName><wsdlFile>src/main/resources/service2.wsdl</wsdlFile><outputDirectory>target/generated-sources</outputDirectory><syncMode>sync</syncMode></configuration></execution></executions></plugin>注意,這段xml配置,如果使用axis2-wsdl2code:wsdl2code命令去生成會報錯,但使用install者可以生成成功。
之后通過中間代碼調用即可。
@Testpublic void testWs() throws Exception{AIServiceStub aiServiceStub=new AIServiceStub();AIRequest aiRequest=new AIRequest();aiRequest.setMsgHeader("test");aiRequest.setMsgBody("test");AIResponse response= aiServiceStub.aIService_visit(aiRequest);System.out.println(response.getRes());}?
轉載于:https://www.cnblogs.com/Gyoung/p/6132710.html
總結
以上是生活随笔為你收集整理的axis2 调用webservice的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 其实昨天去加班也没有干什么事情,就只有3
- 下一篇: 5 分钟上手 ECharts