我用cxf创建了一个带有xew插件的web服务客户端,用于列表展开
问题是null
列表中的内容消失了.例如:
我有一个List<String>
带有字符串和null
-entry的请求
当请求现在到达服务器时,它只包含字符串而不是null
条目.因此示例列表中只有2个条目.
这里是wsdl的一个例子:
[..]
<!-- the request -->
<xsd:element name="createGroup">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="in1" nillable="true" type="ns2:ArrayOfRole"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
[..]
<!-- the list which will be unwrapped -->
<xsd:complexType name="ArrayOfRole">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Role" nillable="true" type="xsd:String"/>
</xsd:sequence>
</xsd:complexType>
Run Code Online (Sandbox Code Playgroud)
我正在使用maven来生成ws客户端
<properties>
<cxf.version>3.0.5</cxf.version>
<jaxbBasic.version>0.6.5</jaxbBasic.version>
</properties>
[..]
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>src/main/java</sourceRoot>
<defaultOptions>
<bindingFiles>
<bindingFile>${basedir}/jaxbBindings.xml</bindingFile>
<bindingFile>${basedir}/jaxwsBindings.xml</bindingFile>
</bindingFiles> …
Run Code Online (Sandbox Code Playgroud) 我有这个演示中<md-autocomplete>
显示的组件问题:
<md-autocomplete ng-pattern="...">
不起作用.我希望如果将某些文本输入Tax
字段(如zzz
),则该字段将被标记为红色,因为正则表达式只接受数字[1..99] ng-pattern="/^[1-9]\d?$/"
.实际上required
工作正常:当字段为空时,它被触发为无效.
我正在寻找javax.xml.soap
除Sun SAAJ之外的替代SOAP()实现.原因是因为我想在IBM JDK 5驱动的Tomcat AS上部署JAX-WS WebService,但是已知问题是Sun SAAJ实现依赖于重新分配的Xerces类(请参阅Ref Impl不能与IBM JDK和SAAJ测试一起使用)案例不再适用于IBM的SDK),唯一的出路就是使用自定义Maven配置文件来实现com.sun.xml.parsers:jaxp-ri
:
<profiles>
<profile>
<id>pre-jdk5-profile</id>
<activation>
<jdk>(,1.4]</jdk>
</activation>
<dependencies>
<dependency>
<groupId>com.sun.xml.parsers</groupId>
<artifactId>jaxp-ri</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
我想删除此配置文件,只需将SOAP实现替换为适用于任何地方的实现.
我认为供应商SOAP实现可能附带Apache Axis/Apache CXF(基于IBM SOAP4J)或JBoss AS - 请根据我的偏好提供信息:
参考文献:
假设我有一个模块A:jar
,其依赖项的运行时和编译集取决于JDK版本.在我的示例中,我有一个pre-jdk6-profile
for JAXB API:在JDK 1.6.0之前,我需要包含jaxb-api-nnn.jar
作为编译依赖项.此个人资料被放置A.pom
.
我也有模块B:war
,这取决于A:jar
.我希望能够在构建服务器上激活此配置文件以构建JDK 1.5.x可交付项.当我在激活给定配置文件的情况下执行Maven时,我收到消息:
mvn -Ppre-jdk6-profile -o install
[WARNING]
Profile with id: 'pre-jdk6-profile' has not been activated.
Run Code Online (Sandbox Code Playgroud)
并且jaxb-api-nnn.jar
在结果中缺失B.war
.但是,如果我在从父级构建时激活此配置文件pom.xml
,则一切正常.这意味着配置文件不是从依赖项继承的,并且父多模块pom.xml能够正确构建所有内容,因为它似乎所有配置文件都在reactor中合并.
将配置文件转换为父pom会使事情变得更糟,因为依赖关系应用于所有其他项目(例如C:ear
).对于此任务是否有很好的解决方案,即,如果任何模块A
依赖于模块B
,那么由配置文件激活的所有编译和运行时依赖关系是否都能正确处理?
项目简介A:jar
如下:
<project ...>
<artifactId>A</artifactId>
<packaging>jar</packaging>
...
<parent>
<artifactId>P</artifactId>
...
</parent>
<profiles>
<profile>
<id>pre-jdk6-profile</id>
<activation>
<jdk>(,1.6.0)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
...
</project>
Run Code Online (Sandbox Code Playgroud) 案例:我想打开SSL连接,localhost
而SSL证书是FQDN的问题.
问题:如果没有特殊处理,(*)
下面的程序将失败并显示以下消息:
PHP Warning: stream_socket_enable_crypto(): Peer certificate CN='myhost.com' did not match expected CN='localhost' in test.php
测试PHP程序:
$fp = stream_socket_client("tcp://localhost:993", $errno, $errstr, 30);
// (*) if commented, the program fails
//stream_context_set_option($fp, 'ssl', 'verify_peer_name', false);
if (!$fp) {
die("Unable to connect: $errstr ($errno)");
}
if (!stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
die("Failed to start SSL");
}
fwrite($fp, "USER god\r\n");
fwrite($fp, "PASS secret\r\n");
while ($motd = fgets($fp)) {
echo $motd;
}
fclose($fp);
Run Code Online (Sandbox Code Playgroud)
由于我有很多遗留代码,我希望通过仅对php.ini
(或CLI)应用更改来获得解决方案,但遗憾的是,以下两种方法都不起作用:
php -d verify_peer_name=false test.php
php -d …
我有以下架构:
<xsd:schema xmlns:bar="http://www.foo.org/bar"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:annox="http://annox.dev.java.net"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
targetNamespace="http://www.foo.org/bar"
jaxb:extensionBindingPrefixes="annox" jaxb:version="2.1" elementFormDefault="qualified">
<xsd:element name="unit" type="bar:unit" />
<xsd:complexType name="unit">
<xsd:annotation>
<xsd:appinfo>
<annox:annotate>@javax.xml.bind.annotation.XmlRootElement(name="unit")</annox:annotate>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:any processContents="skip" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Run Code Online (Sandbox Code Playgroud)
当我解组这个XML时
<unit xmlns="http://www.foo.org/bar">
<text>Name</text>
</unit>
Run Code Online (Sandbox Code Playgroud)
返回的对象是javax.xml.bind.JAXBElement<Unit>
,但我想org.foo.bar.Unit
回来.我需要这个,因为在我的情况下解组是由JAX-RS提供者或SpringWeb隐式发生的.
观察:
<xsd:any processContents="skip" />
声明,JAXB开始返回org.foo.bar.Unit
.<xsd:element name="unit" type="bar:unit" />
声明,JAXB开始返回org.foo.bar.Unit
(虽然需要在解组时禁用验证).因此,我会说,鉴于XSD是证明问题的最小XSD.
问题:为什么JAXB包装org.foo.bar.Unit
成JAXBElement
以上的组合?从我看到的情况来看,XSD类型unit
无法使标签名称unit
与之不同,为什么JAXB需要这种工厂方法呢?
@XmlElementDecl(namespace = "http://www.foo.org/bar", name = "unit")
public JAXBElement<Unit> createUnit(Unit value) { ... }
Run Code Online (Sandbox Code Playgroud)
展示JAXB 2.2.7问题的项目就在这里 …
我的问题涉及编写JAXB插件,特别是JAXB代码模型.
ClassOutline
(及其同伴)和JClass
(和同伴)和CClass
(和同伴)的角色是什么?在查看相应包中的类列表时,不清楚什么是鸡,什么是鸡蛋.
我的解释是CClass
(CPropertyInfo
,CEnumConstant
...)是由XJC在XSD的初稿解析时创建的.然后,一些神奇的发生,这种模型转化为JClass
(JFieldVar
,JEnumConstant
,...),这转变过程中的自定义应用.然后调用插件.ClassOutline
用作这两个模型之间的桥梁.总之看起来非常复杂.
通过这些并行模型,我相信可以通过多种方式获得相同的信息.例如,类字段类型:
JClass#fields()
→交通JFieldVar#type
→交通JType
CClassInfo#getProperties()
→交通CPropertyInfo#baseType
→交通JType
我正在寻找上述模型生命周期的详细解释.谢谢.
我有这个用例.
第一链:
<int:chain input-channel="inserimentoCanaleActivate" output-channel="inserimentoCanalePreRouting">
<int:service-activator ref="inserimentoCanaleActivator" method="activate" />
</int:chain>
Run Code Online (Sandbox Code Playgroud)
这是相关代码:
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EventMessage<ModificaOperativitaRapporto> activate(EventMessage<InserimentoCanale> eventMessage) {
...
// some Database changes
dao.save(myObject);
}
Run Code Online (Sandbox Code Playgroud)
一切都很好.
然后我有另一个链:
<int:chain id="onlineCensimentoClienteChain" input-channel="ONLINE_CENSIMENTO_CLIENTE" output-channel="inserimentoCanaleActivate">
<int:service-activator ref="onlineCensimentoClienteActivator" method="activate" />
<int:splitter expression="payload.getPayload().getCanali()" />
</int:chain>
Run Code Online (Sandbox Code Playgroud)
而相对激活者:
@Override
public EventMessage<CensimentoCliente> activate(EventMessage<CensimentoCliente> eventMessage) {
...
// some Database changes
dao.save(myObject);
}
Run Code Online (Sandbox Code Playgroud)
在CensimentoCliente
如下所述的有效载荷具有List
第一链的有效载荷的,所以用一个分离器我分裂名单上并重新使用第一链的代码.
public interface CensimentoCliente extends Serializable {
Collection<? extends InserimentoCanale> getCanali();
void setCanali(Collection<? extends InserimentoCanale> canali);
...
}
Run Code Online (Sandbox Code Playgroud)
但是,由于每个激活器都获得了他的事务定义(因为第一个激活器可以在没有第二个激活器的情况下生存),我有一个用例,其中事务是分开的.
目标是让两个链的数据库修改成为同一事务的一部分.
有帮助吗? …
在我的应用程序中,我有一些本机代码的包装器,它通过JNI桥调用.此本机代码需要在单独的线程中执行(并行处理).但问题是代码有时会"挂起",因此线程需要"强制"终止.不幸的是我没有找到任何"微妙"的方法:一般建议是告诉线程中的代码优雅地退出,但我不能用这个本机代码(这是上面的第三方代码).
我使用Java Concurrent API进行任务提交:
Future<Integer> processFuture = taskExecutor.submit(callable);
try {
result = processFuture.get(this.executionTimeout, TimeUnit.SECONDS).intValue();
}
catch (TimeoutException e) {
// How to kill the thread here?
throw new ExecutionTimeoutException("Execution timed out (max " + this.executionTimeout / 60 + "min)");
}
catch (...) {
... exception handling for other cases
}
Run Code Online (Sandbox Code Playgroud)
Future#cancel()
只会中断线程,但不会终止它.所以我使用了以下技巧:
class DestroyableCallable implements Callable<Integer> {
private Thread workerThread;
@Override
public Integer call() {
workerThread = Thread.currentThread();
return Integer.valueOf(JniBridge.process(...));
}
public void stopWorkerThread() {
if (workerThread != null) { …
Run Code Online (Sandbox Code Playgroud) 我有一个使用Maven构建的CXF JAX-RS应用程序.我正在努力将其转换为Gradle,但使用Ant XJC任务.
当前版本使用了几个扩展,其中一个是"元素包装"插件的副本,另一个是"jaxb-fluent-api".
我尝试将这两个插件的jar放入xjc类路径中,但是当我运行XJC任务时,我得到以下内容:
java.util.ServiceConfigurationError:com.sun.tools.xjc.Plugin:Provider dk.conspicio.jaxb.plugins.XmlElementWrapperPlugin not a subtype
XmlElementWrapperPlugin类扩展了"com.sun.tools.xjc.Plugin".
知道这里发生了什么吗?
如果重要的话,我的xjc插件的Maven配置看起来像这样:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>xsdtojava</goal>
</goals>
<configuration>
<extensions>
<extension>JAXBXMLElementWrapperPlugin:JAXBXMLElementWrapperPlugin:1.0.0</extension>
<extension>net.java.dev.jaxb2-commons:jaxb-fluent-api:2.1.8</extension>
</extensions>
<xsdOptions>
<xsdOption>
<xsd>${basedir}/src/main/resources/schema/serviceCallResults.xsd</xsd>
<packagename>com.att.sunlight.service.domain.serviceCallResults</packagename>
<extension>true</extension>
<extensionArgs>
<extensionArg>-Xxew</extensionArg>
<extensionArg>-summary ${basedir}/target/xew-summary.txt</extensionArg>
<extensionArg>-instantiate lazy</extensionArg>
<extensionArg>-Xfluent-api</extensionArg>
</extensionArgs>
</xsdOption>
</xsdOptions>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这是我的"build.gradle",只有存储库被省略:
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'war'
group = 'SunlightDataService'
version = '1.2.4-SNAPSHOT'
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
...
}
configurations {
jaxb
}
dependencies {
jaxb …
Run Code Online (Sandbox Code Playgroud) jaxb ×4
java ×3
cxf ×2
jax-ws ×2
angularjs ×1
gradle ×1
javascript ×1
jcodemodel ×1
maven ×1
maven-2 ×1
php ×1
soap ×1
spring ×1
ssl ×1
transactions ×1
web-services ×1
wsdl2java ×1
xjc ×1
xsd ×1