0

我将 From Wso2 esb 和负载平衡概念与服务一起使用,但我有一个错误,这是我的代码:

 <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 和其他返回正确值

4

1 回答 1

0

我发现我的问题在于定义端点 kr 和 mt 不正确我在多服务中的参数应该与 mt 中的源参数兼容被命名为“z”

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

但是 kr 中的参数被命名为“a”

       <endpoint name="KR">
          <address uri="http://D-N-PC-12071:8280/services/Multi/MultiService"/>
       </endpoint>
于 2013-10-21T06:29:50.703 回答