Apache CXF 中WSDiscoveryClient检索设备失败,抓包工具都抓不到?

zq910515 2019-09-30 02:44:38
创建Maven项目,引入:
cxf-services-ws-discovery-api-3.1.8.jar,
cxf-services-ws-discovery-service-3.1.8.jar,
slf4j-jdk14-1.7.25.jar,
jcl-over-slf4j-1.7.25.jar,
然后用WSDiscoveryClient检索不到onvif设备,是怎回事?抓包工具连udp端口3702的数据包都抓不到。

java代码:
public static void main( String[] args )
{
WSDiscoveryClient client = new WSDiscoveryClient();
client.setVersion10();
client.setDefaultProbeTimeout(3000); // timeout 5s
ProbeType probeType = new ProbeType();
probeType.getTypes().add(new QName("tds:Device"));
probeType.getTypes().add(new QName("dn:Network Video Transmitter"));//
System.out.println("Probe:" + client.getAddress());
ProbeMatchesType probeMatchesType = client.probe(probeType);
List<ProbeMatchType> probeMatchTypes = probeMatchesType.getProbeMatch();
for (ProbeMatchType type : probeMatchTypes) {
System.out.println(type.getXAddrs());
}
}


项目pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.wd.discovery</groupId>
<artifactId>maven-wd-discovery</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>maven-wd-discovery</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.25</version>
</dependency>

<dependency>
<groupId>org.apache.cxf.services.ws-discovery</groupId>
<artifactId>cxf-services-ws-discovery-api</artifactId>
<version>3.1.18</version>
</dependency>
<dependency>
<groupId>org.apache.cxf.services.ws-discovery</groupId>
<artifactId>cxf-services-ws-discovery-service</artifactId>
<version>3.1.18</version>
</dependency>


<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>


控制台打印信息:
Probe:soap.udp://239.255.255.250:3702
九月 30, 2019 2:08:14 下午 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://schemas.xmlsoap.org/ws/2005/04/discovery}DiscoveryProxy from class org.apache.cxf.jaxws.support.DummyImpl
九月 30, 2019 2:08:18 下午 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
警告: Interceptor for {http://schemas.xmlsoap.org/ws/2005/04/discovery}DiscoveryProxy#{http://cxf.apache.org/jaxws/dispatch}Invoke has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not receive Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:65)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:309)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:523)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:425)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:403)
at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:396)
at org.apache.cxf.jaxws.DispatchImpl.invokeAsync(DispatchImpl.java:446)
at org.apache.cxf.ws.discovery.WSDiscoveryClient.probe(WSDiscoveryClient.java:386)
at org.apache.cxf.ws.discovery.WSDiscoveryClient.probe(WSDiscoveryClient.java:353)
at com.wd.discovery.maven_wd_discovery.App.main(App.java:28)
Caused by: java.net.SocketTimeoutException: Receive timed out
at java.net.TwoStacksPlainDatagramSocketImpl.receive0(Native Method)
at java.net.TwoStacksPlainDatagramSocketImpl.receive(Unknown Source)
at java.net.DatagramSocket.receive(Unknown Source)
at org.apache.cxf.transport.udp.UDPConduit$UDPBroadcastOutputStream.close(UDPConduit.java:325)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.udp.UDPConduit.close(UDPConduit.java:144)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:63)
... 9 more
...全文
3 点赞 收藏 1
写回复
1 条回复
苏帅呀 04月16日
请问最后怎么解决的
回复 点赞
发动态
发帖子
Java EE
创建于2007-09-28

3.7w+

社区成员

22.5w+

社区内容

J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区公告
暂无公告