Веб-сервис в кластерной среде

#java #web-services #jboss #wsdl #webservice-client

#java #веб-сервисы #jboss #wsdl #веб-сервис-клиент

Вопрос:

У меня есть веб-сервис, работающий на двух кластерах, и балансировщик нагрузки решает, куда пересылать запросы. Из-за правил брандмауэра клиентский компьютер может видеть только балансировщик нагрузки, а два сервера приложений не могут видеть балансировщик нагрузки. У меня есть следующие файлы wsdl в кластерах:

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.1-hudson-10-. -->
<definitions targetNamespace="http://contract.company-europe.com/" name="contractServiceService"
             xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy"
             xmlns:tns="http://contract.company-europe.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
             xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsp:Policy wsu:Id="contractAgreementServicePortBinding_getcontractAgreement_WSAT_Policy"
                xmlns:wsat="http://schemas.xmlsoap.org/ws/2004/10/wsat">
        <wsat:ATAlwaysCapability/>
        <wsat:ATAssertion wsp:Optional="true" ns2:Optional="true"
                          xmlns:ns2="http://schemas.xmlsoap.org/ws/2002/12/policy"/>
    </wsp:Policy>
    <types>
        <xsd:schema>
            <xsd:import namespace="http://contract.company-europe.com/"
                        schemaLocation="schemaLocation="http://loadbalancer/merlin/contractAgreementService?wsdlamp;resource=contractAgreementServiceService_schema.xsd"/>
        </xsd:schema>
    </types>
    <message name="getcontractAgreement">
        <part name="parameters" element="tns:getcontractAgreement"/>
    </message>
    <message name="getcontractAgreementResponse">
        <part name="parameters" element="tns:getcontractAgreementResponse"/>
    </message>
    <message name="IOException">
        <part name="fault" element="tns:IOException"/>
    </message>

    <message name="MerlinBaseException">
        <part name="fault" element="tns:MerlinBaseException"/>
    </message>

    <portType name="contractAgreementService">
        <operation name="getcontractAgreement">
            <input wsam:Action="http://contract.company-europe.com/contractAgreementService/getcontractAgreementRequest"
                   message="tns:getcontractAgreement"/>
            <output wsam:Action="http://contract.company-europe.com/contractAgreementService/getcontractAgreementResponse"
                    message="tns:getcontractAgreementResponse"/>
            <fault message="tns:IOException" name="IOException"
                   wsam:Action="http://contract.company-europe.com/contractAgreementService/getcontractAgreement/Fault/IOException"/>
            <fault message="tns:MerlinBaseException" name="MerlinBaseException"
                   wsam:Action="http://contract.company-europe.com/contractAgreementService/getcontractAgreement/Fault/MerlinBaseException"/>
        </operation>
    </portType>

    <binding name="contractAgreementServicePortBinding" type="tns:contractAgreementService">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <operation name="getcontractAgreement">
            <wsp:PolicyReference URI="#contractAgreementServicePortBinding_getcontractAgreement_WSAT_Policy"/>
            <soap:operation soapAction=""/>
            <input>
                <wsp:PolicyReference URI="#contractAgreementServicePortBinding_getcontractAgreement_WSAT_Policy"/>
                <soap:body use="literal"/>
            </input>
            <output>
                <wsp:PolicyReference URI="#contractAgreementServicePortBinding_getcontractAgreement_WSAT_Policy"/>
                <soap:body use="literal"/>
            </output>
            <fault name="IOException">
                <soap:fault name="IOException" use="literal"/>
            </fault>
            <fault name="MerlinBaseException">
                <soap:fault name="MerlinBaseException" use="literal"/>
            </fault>
        </operation>
    </binding>
    <service name="contractAgreementServiceService">
        <port name="contractAgreementServicePort" binding="tns:contractAgreementServicePortBinding">
            <soap:address location="http://loadbalancer/merlin/contractAgreementService"/>
        </port>
    </service>
</definitions>
  

Правильно ли, что адрес soap и xsd указывают на балансировщик нагрузки, или они должны использовать локальный адрес cluster1 / cluster2?

ОБНОВЛЕНИЕ1

К сожалению, я получил следующее сообщение об ошибке. Это происходит только в кластеризованной среде:

 2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:100) -  - REQUEST URI       =/merlin/contractAgreementService
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:101) -  -           authType=null
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:102) -  -  characterEncoding=utf-8
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:103) -  -      contentLength=273
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:104) -  -        contentType=text/xml; charset=utf-8
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:105) -  -        contextPath=/merlin
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:118) -  -             header=content-type=text/xml; charset=utf-8
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:118) -  -             header=soapaction="http://rental.company-europe.com/contractAgreementService/getContractAgreementRequest"
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:118) -  -             header=host=loadbalancer
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:118) -  -             header=content-length=273
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:118) -  -             header=expect=100-continue
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:118) -  -             header=connection=Keep-Alive
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:121) -  -             locale=en_GB
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:122) -  -             method=POST
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:134) -  -          parameter=wsdl=
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:136) -  -           pathInfo=null
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:137) -  -           protocol=HTTP/1.1
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:138) -  -        queryString=wsdl
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:139) -  -         remoteAddr=10.101.98.79
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:140) -  -         remoteHost=10.101.98.79
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:141) -  -         remoteUser=null
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:142) -  - requestedSessionId=null
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:143) -  -             scheme=http
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:144) -  -         serverName=loadbalancer
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:145) -  -         serverPort=80
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:146) -  -        servletPath=/contractAgreementService
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:147) -  -           isSecure=false
[2011-11-03 09:43:21,937] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:148) -  - ---------------------------------------------------------------
[2011-11-03 09:43:21,937] DEBUG (org.jboss.ws.core.soap.MessageContextAssociation:46) -  - pushMessageContext: org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS@77c1ca7 (Thread http-FXPEARLAP2/10.101.117.5-58080-2)
[2011-11-03 09:43:21,937] DEBUG (org.jboss.ws.core.soap.MessageFactoryImpl:215) -  - createMessage: [contentType=text/xml; charset=utf-8]
[2011-11-03 09:43:21,937] DEBUG (org.jboss.ws.metadata.umdm.EndpointMetaData:732) -  - Configure SOAPBinding
[2011-11-03 09:43:21,937] ERROR (org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS:149) -  - SOAP request exception
java.io.IOException
    at org.apache.coyote.http11.InternalAprInputBuffer.fill(InternalAprInputBuffer.java:763)
    at org.apache.coyote.http11.InternalAprInputBuffer$SocketInputBuffer.doRead(InternalAprInputBuffer.java:792)
    at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:116)
    at org.apache.coyote.http11.InternalAprInputBuffer.doRead(InternalAprInputBuffer.java:703)
    at org.apache.coyote.Request.doRead(Request.java:428)
    at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:297)
    at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:405)
    at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:312)
    at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:162)
    at org.jboss.wsf.common.IOUtils.copyStream(IOUtils.java:69)
    at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:224)
    at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:195)
    at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:447)
    at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:284)
    at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:201)
    at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:134)
    at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.valves.RequestDumperValve.invoke(RequestDumperValve.java:151)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:856)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:566)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)
    at java.lang.Thread.run(Thread.java:662)
[2011-11-03 09:43:21,953] DEBUG (org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS:269) -  - Cannot obtain fault meta data for: class java.io.IOException
[2011-11-03 09:43:21,953] DEBUG (org.jboss.ws.core.soap.MessageContextAssociation:75) -  - popMessageContext: org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS@77c1ca7 (Thread http-FXPEARLAP2/10.101.117.5-58080-2)
[2011-11-03 09:43:21,953] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:154) -  - ---------------------------------------------------------------
[2011-11-03 09:43:21,953] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:155) -  -           authType=null
[2011-11-03 09:43:21,953] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:156) -  -      contentLength=-1
[2011-11-03 09:43:21,953] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:157) -  -        contentType=text/xml;charset=UTF-8
[2011-11-03 09:43:21,953] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:168) -  -             header=X-Powered-By=Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181439)/JBossWeb-2.0
[2011-11-03 09:43:21,953] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:168) -  -             header=Content-Type=text/xml;charset=UTF-8
[2011-11-03 09:43:21,953] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:168) -  -             header=Transfer-Encoding=chunked
[2011-11-03 09:43:21,953] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:168) -  -             header=Date=Thu, 03 Nov 2011 09:43:21 GMT
[2011-11-03 09:43:21,968] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:168) -  -             header=Connection=close
[2011-11-03 09:43:21,968] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:170) -  -            message=null
[2011-11-03 09:43:21,968] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:171) -  -         remoteUser=null
[2011-11-03 09:43:21,968] INFO  (org.apache.catalina.core.ContainerBase.[jboss.web].[localhost]:172) -  -             status=500
  

Вы знаете, что это значит? Я помещаю некоторые журналы в саму контрактную службу и не вижу их, поэтому могут быть какие-то проблемы с запросом?

Комментарии:

1. Разве эта строка не выглядит странно? schemaLocation="schemaLocation="http://loadbalancer/merlin/contractAgreementService?wsdlamp;resource=contractAgreementServiceService_schema.xsd"

Ответ №1:

Да, это правильно. Потому что это абстрагирует тот факт, что у вас есть балансировщик нагрузки, и вы действительно можете добавлять все больше и больше узлов в будущем, ничего не меняя

Ответ №2:

Вы сказали, что ваши серверы приложений не могут получить доступ к loadbalancer. Может ли быть так, что ваши узлы кластера пытаются достичь loadbalancer для schemalocation и не могут этого сделать?

Если это проблема, вы можете попробовать использовать относительный URI для вашего schemalocation.

Также вы можете попробовать исправить schemaLocation="schemaLocation="http:... строку.