0

我创建了 Web 服务,它可以在 Glassfish 3.1.1 上使用 https,当我尝试连接到 Web 服务时出现错误。痕迹:

com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection timed out: connect
at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:117)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:194)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:122)
at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:95)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:626)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:585)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:570)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:467)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:308)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:146)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:129)
at $Proxy32.getGUIDE(Unknown Source)
at webserviceclient.WebServiceClient.getGUIDE(WebServiceClient.java:56)
at webserviceclient.WebServiceClient.main(WebServiceClient.java:38)
    Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
at sun.net.www.http.HttpClient$1.run(HttpClient.java:430)
at sun.net.www.http.HttpClient$1.run(HttpClient.java:428)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.http.HttpClient.privilegedOpenServer(HttpClient.java:427)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:468)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:270)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:327)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:974)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1090)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:105)

当我在浏览器“?Tester”中尝试时,server.log 中的错误

[#|2012-10-03T15:38:24.250+0600|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=418;_ThreadName=Thread-2;|parsing WSDL...

|#]

[#|2012-10-03T15:38:24.359+0600|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=418;_ThreadName=Thread-2;|[ERROR] java.security.cert.CertificateException: No subject alternative names present

Failed to read the WSDL document: https://192.168.40.2/WebService/NSI_NBRK?WSDL, because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not <wsdl:definitions>.|#]

[#|2012-10-03T15:38:24.359+0600|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=418;_ThreadName=Thread-2;|[ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s): 

 At least one WSDL with at least one service definition needs to be provided.|#]

[#|2012-10-03T15:38:24.360+0600|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=418;_ThreadName=Thread-2;|  Failed to parse the WSDL.|#]

[#|2012-10-03T15:38:24.360+0600|INFO|glassfish3.1.1|javax.enterprise.webservices.org.glassfish.webservices.monitoring|_ThreadID=418;_ThreadName=Thread-2;|Invoking wsimport with https://192.168.40.2/WebService/NSI_NBRK?WSDL|#]
[#|2012-10-03T15:38:24.361+0600|SEVERE|glassfish3.1.1|javax.enterprise.webservices.org.glassfish.webservices.monitoring|_ThreadID=418;_ThreadName=Thread-2;|wsimport failed|#]

wsdl:

<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.1.1-b09 (branches/2.1-6834; 2011-07-16T17:14:48+0000) JAXWS-RI/2.2.5-promoted-b04 JAXWS/2.2. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.1.1-b09 (branches/2.1-6834; 2011-07-16T17:14:48+0000) JAXWS-RI/2.2.5-promoted-b04 JAXWS/2.2. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://service/" name="NSI_NBRK">
<types>
<xsd:schema>
<xsd:import namespace="http://service/" schemaLocation="./NSI_NBRK.xsd"/>
</xsd:schema>
</types>
<message name="GET_GUIDE">
<part name="parameters" element="tns:GET_GUIDE"/>
</message>
<message name="GET_GUIDEResponse">
<part name="parameters" element="tns:GET_GUIDEResponse"/>
</message>
<portType name="Service">
<operation name="GET_GUIDE">
<input wsam:Action="http://service/Service/GET_GUIDERequest" message="tns:GET_GUIDE"/>
<output wsam:Action="http://service/Service/GET_GUIDEResponse" message="tns:GET_GUIDEResponse"/>
</operation>
</portType>
<binding name="ServicePortBinding" type="tns:Service">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="GET_GUIDE">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="NSI_NBRK">
<port name="ServicePort" binding="tns:ServicePortBinding">
<soap:address location="https://192.168.40.2/WebService/NSI_NBRK"/>
</port>
</service>
</definitions>

和 xsd 架构:

<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.1.1-b09 (branches/2.1-6834; 2011-07-16T17:14:48+0000) JAXWS-RI/2.2.5-promoted-b04 JAXWS/2.2. --><xs:schema xmlns:tns="http://service/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://service/">

<xs:element name="GET_GUIDE" type="tns:GET_GUIDE"/>

<xs:element name="GET_GUIDEResponse" type="tns:GET_GUIDEResponse"/>

<xs:complexType name="GET_GUIDE">
<xs:sequence>
<xs:element name="arg0" type="tns:serviceRequest" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="serviceRequest">
<xs:sequence>
<xs:element name="beginDate" type="xs:dateTime" minOccurs="0"/>
<xs:element name="endDate" type="xs:dateTime" minOccurs="0"/>
<xs:element name="guideCode" type="tns:guideCode" minOccurs="0"/>
<xs:element name="type" type="tns:guideType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="GET_GUIDEResponse">
<xs:sequence>
<xs:element name="return" type="tns:serviceResponse" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="serviceResponse">
<xs:sequence>
<xs:element name="errCode" type="xs:int"/>
<xs:element name="errMsg" type="xs:string" minOccurs="0"/>
<xs:element name="result" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:simpleType name="guideCode">
<xs:restriction base="xs:string">
<xs:enumeration value="NSI_NBRK_BANK"/>
<xs:enumeration value="NSI_NBRK_CRCY_COURSE"/>
<xs:enumeration value="NSI_NBRK_KNP"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="guideType">
<xs:restriction base="xs:string">
<xs:enumeration value="FULL"/>
<xs:enumeration value="CHAD"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

还有web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <session-config>
        <session-timeout>300</session-timeout>
    </session-config>
    <security-constraint>
        <display-name>Constraint</display-name>
        <web-resource-collection>
            <web-resource-name>service</web-resource-name>
            <description>service</description>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <description>service</description>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
</web-app>
4

1 回答 1

0

似乎是连接问题。尝试从 Web 浏览器查看 wsdl 以检查连接性,或者只是对 192.168.40.2 进行 pin 操作

你得到什么例外。

检查此网址是否对您有帮助?

http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/

于 2012-10-03T09:43:29.617 回答