powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / Проблема доступа к веб-сервису
2 сообщений из 2, страница 1 из 1
Проблема доступа к веб-сервису
    #37911295
krab
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здравствуйте, есть простой веб - сервис:

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
@Stateless
@WebService
public class SubsidiaryWebservice {
	
	@EJB
	private SubsidiaryService service;
	
	@WebMethod
	public Subsidiary getSubsidiaryById(Long id){
		return service.find(id);
	}

}



Jboss генерит для него вот такой вот wsdl файл:
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="SubsidiaryWebserviceService" targetNamespace="http://webservices.ttk.kmware.com/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservices.ttk.kmware.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <wsdl:types>
<xs:schema elementFormDefault="unqualified" targetNamespace="http://webservices.ttk.kmware.com/" version="1.0" xmlns:tns="http://webservices.ttk.kmware.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="getSubsidiaryById" type="tns:getSubsidiaryById"/>
<xs:element name="getSubsidiaryByIdResponse" type="tns:getSubsidiaryByIdResponse"/>
<xs:complexType name="getSubsidiaryById">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="xs:long"/>
    </xs:sequence>
  </xs:complexType>
<xs:complexType name="getSubsidiaryByIdResponse">
    <xs:sequence>
      <xs:element minOccurs="0" name="return" type="tns:subsidiary"/>
    </xs:sequence>
  </xs:complexType>
<xs:complexType name="subsidiary">
    <xs:complexContent>
      <xs:extension base="tns:abstractEntity">
        <xs:sequence>
          <xs:element minOccurs="0" name="connEmail" type="xs:string"/>
          <xs:element minOccurs="0" name="id" type="xs:long"/>
          <xs:element minOccurs="0" name="name" type="xs:string"/>
          <xs:element minOccurs="0" name="techEmail" type="xs:string"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
<xs:complexType name="abstractEntity">
    <xs:sequence>
      <xs:element minOccurs="0" name="createdAt" type="xs:dateTime"/>
      <xs:element minOccurs="0" name="lastUpdatedAt" type="xs:dateTime"/>
      <xs:element minOccurs="0" name="version" type="xs:long"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="getSubsidiaryById">
    <wsdl:part element="tns:getSubsidiaryById" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="getSubsidiaryByIdResponse">
    <wsdl:part element="tns:getSubsidiaryByIdResponse" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="SubsidiaryWebservice">
    <wsdl:operation name="getSubsidiaryById">
      <wsdl:input message="tns:getSubsidiaryById" name="getSubsidiaryById">
    </wsdl:input>
      <wsdl:output message="tns:getSubsidiaryByIdResponse" name="getSubsidiaryByIdResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="SubsidiaryWebserviceServiceSoapBinding" type="tns:SubsidiaryWebservice">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getSubsidiaryById">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="getSubsidiaryById">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="getSubsidiaryByIdResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="SubsidiaryWebserviceService">
    <wsdl:port binding="tns:SubsidiaryWebserviceServiceSoapBinding" name="SubsidiaryWebservicePort">
      <soap:address location="http://192.168.1.32:8080/RQ/SubsidiaryWebservice"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>



В standalone.xml такое:

Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
<subsystem xmlns="urn:jboss:domain:webservices:1.1">	
            <modify-wsdl-address>true</modify-wsdl-address>	
            <wsdl-host>192.168.1.32</wsdl-host>	
            <wsdl-port>8080</wsdl-port>	
            <endpoint-config name="Standard-Endpoint-Config"/>	
            <endpoint-config name="Recording-Endpoint-Config">	
                <pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">	
                    <handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>	
                </pre-handler-chain>	
            </endpoint-config>
        </subsystem>




Далее создаю обычный клиент у себя

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
import javax.jws.WebMethod;

@WebService(name = "SubsidiaryWebservice", targetNamespace = "http://webservices.ttk.kmware.com/")
@XmlSeeAlso({
    ObjectFactory.class
})
public interface SubsidiaryWebservice {

    @WebMethod
    @WebResult(targetNamespace = "")
    @RequestWrapper(localName = "getSubsidiaryById", targetNamespace = "http://webservices.ttk.kmware.com/", className = "myau.com.GetSubsidiaryById")
    @ResponseWrapper(localName = "getSubsidiaryByIdResponse", targetNamespace = "http://webservices.ttk.kmware.com/", className = "myau.com.GetSubsidiaryByIdResponse")
    public Subsidiary getSubsidiaryById(
        @WebParam(name = "arg0", targetNamespace = "")
        Long arg0);

}


@WebServiceClient(name = "SubsidiaryWebserviceService", targetNamespace = "http://webservices.ttk.kmware.com/", wsdlLocation = "http://192.168.1.32:8080/RQ/SubsidiaryWebservice?wsdl")
public class SubsidiaryWebserviceService
    extends Service
{

    private final static URL SUBSIDIARYWEBSERVICESERVICE_WSDL_LOCATION;
    private final static Logger logger = Logger.getLogger(myau.SubsidiaryWebserviceService.class.getName());

    static {
        URL url = null;
        try {
            url = new URL( "http://192.168.1.32:8080/RQ/SubsidiaryWebservice?wsdl");
        } catch (MalformedURLException e) {
            logger.warning("Failed to create URL for the wsdl Location,  retrying as a local file");
            logger.warning(e.getMessage());
        }
        SUBSIDIARYWEBSERVICESERVICE_WSDL_LOCATION = url;
    }

    public SubsidiaryWebserviceService(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public SubsidiaryWebserviceService() {
        super(SUBSIDIARYWEBSERVICESERVICE_WSDL_LOCATION, new QName("http://webservices.ttk.kmware.com/", "SubsidiaryWebserviceService"));
    }

    /**
     * 
     * @return
     *     returns SubsidiaryWebservice
     */
    @WebEndpoint(name = "SubsidiaryWebservicePort")
    public SubsidiaryWebservice getSubsidiaryWebservicePort() {
        return super.getPort(new QName("http://webservices.ttk.kmware.com/", "SubsidiaryWebservicePort"), SubsidiaryWebservice.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns SubsidiaryWebservice
     */
    @WebEndpoint(name = "SubsidiaryWebservicePort")
    public SubsidiaryWebservice getSubsidiaryWebservicePort(WebServiceFeature... features) {
        return super.getPort(new QName("http://webservices.ttk.kmware.com/", "SubsidiaryWebservicePort"), SubsidiaryWebservice.class, features);
    }

}



Классы - обвертки не показываю, так как скорее всего проблема не в них

Далее пытаюсь обратится к веб-сервису:
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
public class SubsidiaryWebservicePortClient
{
  public static void main(String [] args)
  {
    SubsidiaryWebserviceService subsidiaryWebserviceService = new SubsidiaryWebserviceService();
    SubsidiaryWebservice subsidiaryWebservice = subsidiaryWebserviceService.getSubsidiaryWebservicePort();
    System.out.println(subsidiaryWebservice.getSubsidiaryById(67L));
  }
}



Выдает ошибку:
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://192.168.1.32:8080/RQ/SubsidiaryWebservice?wsdl. It failed with: 
	Connection refused: connect.
	at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:172)
	at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:153)
	at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:284)
	at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:246)
	at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:197)
	at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:187)
	at weblogic.wsee.jaxws.spi.WLSServiceDelegate.<init>(WLSServiceDelegate.java:84)
	at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegate.<init>(WLSProvider.java:598)
	at weblogic.wsee.jaxws.spi.WLSProvider.createServiceDelegate(WLSProvider.java:120)
	at weblogic.wsee.jaxws.spi.WLSProvider.createServiceDelegate(WLSProvider.java:112)
	at weblogic.wsee.jaxws.spi.WLSProvider.createServiceDelegate(WLSProvider.java:83)
	at javax.xml.ws.Service.<init>(Service.java:56)
	at test.SubsidiaryWebserviceService.<init>(SubsidiaryWebserviceService.java:45)
	at test.SubsidiaryWebservicePortClient.main(SubsidiaryWebservicePortClient.java:11)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
	at java.net.Socket.connect(Socket.java:529)
	at java.net.Socket.connect(Socket.java:478)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
	at sun.net.www.http.HttpClient.New(HttpClient.java:306)
	at sun.net.www.http.HttpClient.New(HttpClient.java:323)
	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
	at java.net.URL.openStream(URL.java:1010)
	at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:842)
	at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:289)
	at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:138)
	... 12 more



Если же я поставлю в настройках JBoss в standalone.xml:

Код: xml
1.
<wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>


т.е. localhost
то он мне сгенерит в wsdl файле:
Код: xml
1.
<soap:address location="http://localhost:8080/RQ/SubsidiaryWebservice"/> 



В клиенте я ставлю соответственно:
Код: java
1.
 url = new URL( "http://localhost:8080/RQ/SubsidiaryWebservice?wsdl");


И локально все работает.

Вопрос, как мне сделать так, чтоб обращение к веб - сервису было удаленное по айпи:порт?
Айпи не тот? локальный не подходит?
И еще, как заставить Jboss сгенерить мне soap:address location не такой " http://localhost:8080/RQ/SubsidiaryWebservice", а такой к примеру " http://localhost:8080/RQ/services/SubsidiaryWebservice" ?

Заранее спасибо.
...
Рейтинг: 0 / 0
Проблема доступа к веб-сервису
    #37911486
krab
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Разобрался, помогла эта строчка в standalone.xml:

Код: xml
1.
<wsdl-host>jbossws.undefined.host</wsdl-host>



Как заставить Jboss сгенерить мне soap:address location не такой " http://localhost:8080/RQ/SubsidiaryWebservice", а такой к примеру " http://localhost:8080/RQ/services/SubsidiaryWebservice" ?
Вопрос актуальный :)
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / Проблема доступа к веб-сервису
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]