是通过Axis2 1.5.4线程安全的WSDL2JAVA(使用XMLBeans绑定选项)生成的存根吗?
实际上我已经为一个Web服务创建了一个Stub,我通过多个线程调用它.我已经配置了自己的MultiThreadedHttpConnectionmanager设置,HTTPConstants.REUSE_HTTP_CLIENT但我看到一些NullPointerExceptions stub._getServiceClient().cleanupTransport,我在每次调用后调用.
有时线程也会挂起.
同时我注意到在Web Service操作方法中生成的Stub中,在finally块中已经调用了cleanup().stub._getServiceClient().cleanupTransport我以后不应该打电话给自己吗?
我的代码:
httpConnMgr = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = httpConnMgr.getParams();
if (params == null) {
params = new HttpConnectionManagerParams();
}
params.setDefaultMaxConnectionsPerHost(numberOfThreads);
httpConnMgr.setParams(params);
HttpClient httpClient = new HttpClient(httpConnMgr);
service = new Service1Stub(this.endPointAddress);
service._getServiceClient().getOptions()
.setTimeOutInMilliSeconds(this.timeOut);
service._getServiceClient().getOptions()
.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
service._getServiceClient().getOptions()
.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION, Boolean.FALSE);
service._getServiceClient()
.getOptions()
.setProperty(HTTPConstants.SO_TIMEOUT, (int) (this.timeOut));
service._getServiceClient()
.getOptions()
.setProperty(HTTPConstants.CONNECTION_TIMEOUT,
(int) (this.timeOut));
service._getServiceClient().getServiceContext().getConfigurationContext()
.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
Run Code Online (Sandbox Code Playgroud)
同时在生成的存根中,我注意到已经调用了cleanUp:
finally {
_messageContext.getTransportOut().getSender().cleanup(_messageContext);
}
Run Code Online (Sandbox Code Playgroud)
任何建议都会有很大帮助.谢谢.
我按如下方式配置了axistools-maven-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<wsdlDirectory>/src/main/resources</wsdlDirectory>
<wsdlFiles>
<wsdlFile>adjustment.wsdl</wsdlFile>
</wsdlFiles>
<keep>true</keep>
<allElements>true</allElements>
<outputDirectory>/src/main/java</outputDirectory>
<subPackageByFileName>true</subPackageByFileName>
<useEmitter>true</useEmitter>
<wsdlVersion>2</wsdlVersion>
</configuration>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但我的wsdl文件没有被正确引用.配置是否正确?
我总是得到以下信息
[INFO] Nothing to generate. All WSDL files are up to date.
Run Code Online (Sandbox Code Playgroud) 我正在创建一个将访问Web服务的java库,但是库将在不同的平台中调用,因此我们使用ksoap2和ksoap2-android为不同的平台生成帮助程序类.问题是我们有两组生成的类/方法,它们的签名是等价的,但是没有公开共享Java接口 - 所以我无法想办法从我的主代码中调用它们.
一个简化的例子:
//generated for Android
class A {
public String sayHi() {
return "Hi A";
}
}
//generated for j2se
class B {
public String sayHi() {
return "Hi B";
}
}
//main code - don't know how to do this
XXX talker = TalkerFactory.getInstance()
String greeting = talker.sayHi()
Run Code Online (Sandbox Code Playgroud)
当然,最后一部分是伪代码.具体来说,如何在一个对象的实例上调用sayHi(),我不知道编译时的类型,哪个不符合特定的接口?我希望有一些方法可以做到这一点,无需手动编辑所有生成的类来添加"实现iTalker".
我正在使用 Tomcat 6 和 CXF 3 来实现一些 Web 服务。我需要在本地服务器上使用 wsdl2java 命令生成客户端代码。它适用于 http 协议:
wsdl2java -frontend jaxws21 -p com.activenetwork.iam.ws.client -d "D:\devtools\workspace\TestClient\src" -encoding utf-8 -client -V http://localhost:8080/IAM/services/employee?wsdl
Run Code Online (Sandbox Code Playgroud)
但是,在我将服务器更新为 https 协议后,该命令不再起作用
wsdl2java -frontend jaxws21 -p com.activenetwork.iam.ws.client -d "D:\devtools\workspace\TestClient\src" -encoding utf-8 -client -V https://localhost:8443/IAM/services/employee?wsdl
Run Code Online (Sandbox Code Playgroud)
我得到以下错误:
Loading FrontEnd jaxws21 ...
Loading DataBinding jaxb ...
wsdl2java -frontend jaxws21 -p com.activenetwork.iam.ws.client -d D:\devtools\workspace\TestClient\src -encoding utf-8 -client -V https://localhost:8443/IAM/services/employee?wsdl
wsdl2java - Apache CXF 3.0.0-milestone2
WSDLToJava Error: org.apache.cxf.wsdl11.WSDLRuntimeException: FAIL_TO_CREATE_WSDL_DEFINITION
org.apache.cxf.tools.common.ToolException: org.apache.cxf.wsdl11.WSDLRuntimeException: FAIL_TO_CREATE_WSDL_DEFINITION
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:420)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
at …Run Code Online (Sandbox Code Playgroud) 见下文,我提到了 3 个项目。
Common
Age.xsd (namespace: http://xmlns.common/age)
generated/common/xmlns/age/AgeType.java
pom.xml (cxf-xjc-plugin xsdtojava)
Person
PersonService.wsdl (imports Age.xsd in wsd:types)
generated/com/person/AgeType.java
pom.xml (cxf-codegen-plugin wsdl2java)
Animal
AnimalService.wsdl (imports Age.xsd in wsd:types)
generated/com/animal/AgeType.java
pom.xml (cxf-codegen-plugin wsdl2java)
Run Code Online (Sandbox Code Playgroud)
无论AnimalService.wsdl与PersonService.wsdl进口Age.xsd架构所提到如下:
<wsdl:definitions xmlns:cn="http://xmlns.common/age"
<wsdl:types>
<xsd:schema>
<xsd:import
namespace="http://xmlns.common/age"
schemaLocation="classpath:/common/xmlns/age/Age.xsd" />
</xsd:import>
</xsd:schema>
<!-- cn:AgeType used in output message -->
<!-- ignored -->
</wsdl:definitions>
Run Code Online (Sandbox Code Playgroud)
题:
如何分辨cxf-codegen wsdl2java以不生成代码AgeType(在命名空间中的http://xmlns.common/age)和使用common.xmlns.age.AgeType代替com.person.AgeType和com.animal.AgeType在各自项目通过提供Common项目作为依赖?
我目前正在将旧的轴 wsclient 更新为 cxf(jaxb 数据绑定)客户端,现在存在差异,如何list/array处理。
让我用一个例子来解释一下:
WSDL
<xsd:complexType name="ArrayOfString">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="string" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
Run Code Online (Sandbox Code Playgroud)
这是另一个复杂类型
<xsd:complexType name="CustomParameter">
<xsd:sequence>
<xsd:element minOccurs="0" name="values" nillable="true" type="tns:ArrayOfString"/>
</xsd:sequence>
</xsd:complexType>
Run Code Online (Sandbox Code Playgroud)
现在,当尝试在 cxf 中访问此属性时,需要另外从列表包装器中获取值
CustomParameter.getValues().getString(); // returns List<String>
Run Code Online (Sandbox Code Playgroud)
Axis 确实会自动解开这个,因为您仅通过以下方式获得了数组
CustomParameter.getValues() // returns String[]
Run Code Online (Sandbox Code Playgroud)
我的问题是,在 cxf 中可以做到这一点吗?
我的 wsdl 的一部分:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://ws611.webservice.adapters.company.de" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://ws611.webservice.adapters.company.de" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://usermanagement.ws611.webservice.company.de"
xmlns:ns1="http://ws611.webservice.company.de" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws611.webservice.company.de">
<xsd:complexType name="AuthenticationToken">
<xsd:sequence>
<xsd:element minOccurs="0" name="password" nillable="true" type="xsd:string"/>
<xsd:element …Run Code Online (Sandbox Code Playgroud) 我的服务正在使用肥皂服务。目标服务可以添加新字段,只要我们收到所需的所有字段,就不会破坏我们的服务。我正在使用 CXF 从 WSDL 生成 java 代码,每当它找到新字段时就会中断。是否可以将 CXF 配置为忽略新字段?
错误是这样的
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"http://www.a.com/sed/b/products/2014/03/types", local:"BidOnly"). Expected elements are <{http://www.a.com/sed/b/products/2014/03/types}SaleTeam>,
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:905) ~[cxf-rt-databinding-jaxb-3.2.0.jar:3.2.0]
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:711) ~[cxf-rt-databinding-jaxb-3.2.0.jar:3.2.0]
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:172) ~[cxf-rt-databinding-jaxb-3.2.0.jar:3.2.0]
Run Code Online (Sandbox Code Playgroud) 以下命令曾经完美地工作:
C:\tools\apache-cxf-3.3.1\bin\wsdl2java -client -d generated foo.wsdl
Run Code Online (Sandbox Code Playgroud)
它不再适用于最新版本的 JDK - 12。我已经下载了最新版本的 Apache CXF,但仍然遇到相同的错误:
-Djava.endorsed.dirs=C:\tools\apache-cxf-3.3.1\bin\..\lib\endorsed is not supported. Endorsed standards and standalone APIs
in modular form will be supported via the concept of upgradeable modules.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Run Code Online (Sandbox Code Playgroud)
谁能提供有关如何解决此问题的提示?
如果可能,如何获取Axis在我的应用程序中调用/检索的原始XML请求/响应?
我正在使用Axis附带的WSDL2Java来生成Java存根.
编辑:
我目前拥有的是一个使用Axis处理远程API调用的应用程序.
其中一个要求是在会话中"存储"来自这些调用的所有XML请求/响应,以便它在JSP中可用(用于调试目的).我怎样才能做到这一点?
我尝试编写一个自定义处理程序,extends BasicHandler但在该处理程序中,我仍然无法从中获取HttpServletRequest/ HttpServletResponse对MessageContext
我有一个要求,根据该要求,我必须基于wsdl文件创建Axis2 Web服务.我已经有了wsdl文件.我之前一直在使用wsdl2java来创建Web服务客户端,但我不知道如何使用给定的wsdl文件创建Web服务.有人可以帮我提供正确的命令或选项.
另外,我需要在WAS 6.1和JBoss 5.1.0 GA上发布它,应该为此做些什么.