2013-10-13 77 views
0

平衡我使用WSO2 ESB和負載均衡的概念與服務隊,但我有一個錯誤,這是我的代碼:使用負載wso2esb

<proxy xmlns="http://ws.apache.org/ns/synapse" name="MultiAdd" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> 
<target> 
    <inSequence> 
    <log level="full"/> 
    <log level="full" category="FATAL"/> 
    <property xmlns:tem="http://tempuri.org/" name="AParam" expression="//tem:SumSerVise/tem:a" scope="default" type="INTEGER"/> 
    <property xmlns:tem="http://tempuri.org/" name="BParam" expression="//tem:SumSerVise/tem:b" scope="default" type="INTEGER"/> 
    <log level="custom"> 
     <property name="AParam" expression="$ctx:AParam"/> 
     <property name="BParam" expression="$ctx:BParam"/> 
    </log> 
    <payloadFactory> 
     <format> 
      <p:SumSerVise xmlns:p="http://tempuri.org/"> 
       <!--Exactly 1 occurrence--> 
       <s:a xmlns:s="http://tempuri.org/">$1</s:a> 
       <!--Exactly 1 occurrence--> 
        <s:b xmlns:s="http://tempuri.org/">$2</s:b> 
       </p:SumSerVise> 
       </format> 
       <args> 
       <arg expression="$ctx:AParam"/> 
       <arg expression="$ctx:BParam"/> 
       </args> 
      </payloadFactory> 
      <log level="full"/> 
      <send receive="SeqOne"> 
       <endpoint> 
       <address uri="http://D-N-PC-12071:8280/services/Add"/> 
       </endpoint> 
      </send> 
     </inSequence> 
     <outSequence> 
      <log level="full"/> 
      <send/> 
     </outSequence> 
    </target> 
    <publishWSDL> 
     <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://tempuri.org/"> 
      <wsdl:types> 
       <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/"> 
       <s:element name="SumSerVise"> 
        <s:complexType> 
         <s:sequence> 
          <s:element minOccurs="1" maxOccurs="1" name="a" type="s:int"/> 
          <s:element minOccurs="1" maxOccurs="1" name="b" type="s:int"/> 
         </s:sequence> 
        </s:complexType> 
       </s:element> 
       <s:element name="SumSerViseResponse"> 
        <s:complexType> 
         <s:sequence> 
          <s:element minOccurs="1" maxOccurs="1" name="SumSerViseResult" type="s:int"/> 
         </s:sequence> 
        </s:complexType> 
       </s:element> 
       </s:schema> 
      </wsdl:types> 
      <wsdl:message name="SumSerViseSoapIn"> 
       <wsdl:part name="parameters" element="tns:SumSerVise"/> 
      </wsdl:message> 
      <wsdl:message name="SumSerViseSoapOut"> 
       <wsdl:part name="parameters" element="tns:SumSerViseResponse"/> 
      </wsdl:message> 
      <wsdl:portType name="ServiceSoap"> 
       <wsdl:operation name="SumSerVise"> 
       <wsdl:input message="tns:SumSerViseSoapIn"/> 
       <wsdl:output message="tns:SumSerViseSoapOut"/> 
       </wsdl:operation> 
      </wsdl:portType> 
      <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap"> 
       <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> 
       <wsdl:operation name="SumSerVise"> 
       <soap:operation soapAction="http://tempuri.org/SumSerVise" style="document"/> 
       <wsdl:input> 
        <soap:body use="literal"/> 
       </wsdl:input> 
       <wsdl:output> 
        <soap:body use="literal"/> 
       </wsdl:output> 
       </wsdl:operation> 
      </wsdl:binding> 
      <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap"> 
       <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/> 
       <wsdl:operation name="SumSerVise"> 
       <soap12:operation soapAction="http://tempuri.org/SumSerVise" style="document"/> 
       <wsdl:input> 
        <soap12:body use="literal"/> 
       </wsdl:input> 
       <wsdl:output> 
        <soap12:body use="literal"/> 
       </wsdl:output> 
       </wsdl:operation> 
      </wsdl:binding> 
      <wsdl:service name="Service"> 
       <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap"> 
       <soap:address location="http://localhost/SumServices/Service.asmx"/> 
       </wsdl:port> 
       <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12"> 
       <soap12:address location="http://localhost/SumServices/Service.asmx"/> 
       </wsdl:port> 
      </wsdl:service> 
     </wsdl:definitions> 
    </publishWSDL> 
    <description></description> 
    </proxy> 

,這是我的順序:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="SeqOne"> 
<log level="full"/> 
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:m0="http://tempuri.org/" name="CParam" expression="//m0:SumSerViseResponse/m0:SumSerViseResult" scope="default" type="INTEGER"/> 
<log level="custom"> 
    <property xmlns:ns="http://org.apache.synapse/xsd" name="CParam" expression="$ctx:CParam"/> 
</log> 
<payloadFactory> 
    <format> 
    <p:MultiService xmlns:p="http://tempuri.org/"> 
     <!--Exactly 1 occurrence--> 
      <s:z xmlns:s="http://tempuri.org/">$1</s:z> 
     </p:MultiService> 
    </format> 
    <args> 
     <arg xmlns:ns="http://org.apache.synapse/xsd" expression="$ctx:CParam"/> 
    </args> 
    </payloadFactory> 
    <log level="full"/> 
    <send> 
    <endpoint> 
     <loadbalance algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin"> 
      <endpoint name="mt"> 
       <address uri="http://D-N-PC-12071:8280/services/MultiService/MultiService"/> 
      </endpoint> 
      <endpoint name="KR"> 
       <address uri="http://D-N-PC-12071:8280/services/Multi/MultiService"/> 
      </endpoint> 
     </loadbalance> 
    </endpoint> 
    </send> 
</sequence>  

當使用負載平衡其中一個服務返回值0和其他返回正確的值

回答

0

我發現我的問題是在定義端點kr和mt不正確 我的參數multiservic c應與源兼容的MT 參數被命名爲「Z」

 <endpoint name="mt"> 
      <address uri="http://D-N-PC-12071:8280/services/MultiService/MultiService"/> 
     </endpoint> 

但KR參數被命名爲「一」

 <endpoint name="KR"> 
      <address uri="http://D-N-PC-12071:8280/services/Multi/MultiService"/> 
     </endpoint>