1

あいさつサービスを作成するための WSDL を作成しました。以下は WSDL です。

この wsdl を使用して、ミュールの cxf:proxy-service を使用して Web サービスを生成および公開しています。

これは私にエラーを与えています。

この WSDL の何が問題なのかを確認してください。

<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="HelloService"
    targetNamespace="http://example.org/HelloService"
    xmlns:tns="http://example.org/HelloService" 
    xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"  
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <wsdl:types>
        <xsd:schema targetNamespace="http://example.org/HelloService" >
              <xsd:element name="LastName">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="lName" type="xsd:string"/>
                  </xsd:sequence>
                </xsd:complexType>
              </xsd:element>
              <xsd:element name="FirstName">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="fName" type="xsd:string"/>
                  </xsd:sequence>
                </xsd:complexType>
              </xsd:element>

              <xsd:element name="Greeting">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="greet" type="xsd:string"/>
                  </xsd:sequence>
                </xsd:complexType>
              </xsd:element>
            </xsd:schema>
    </wsdl:types>

    <wsdl:message name="shortRequest">
        <wsdl:part type="tns:LastName" name="lastName"/>
      </wsdl:message>

      <wsdl:message name="fullRequest">
        <wsdl:part type="tns:FirstName" name="firstName"/>
        <wsdl:part type="tns:LastName" name="lastName"/>
      </wsdl:message>

      <wsdl:message name="greetingResponse">
        <wsdl:part type="tns:greeting" name="greetings"/>
      </wsdl:message>   


      <wsdl:portType name="HelloServicePortType">

        <wsdl:operation name="simpleGreeting">
          <wsdl:input message="tns:shortRequest" name="shortRequest" />
          <wsdl:output message="tns:greetingResponse" name="greetingResponse" />
        </wsdl:operation>

        <wsdl:operation name="fullGreeting">
          <wsdl:input message="tns:fullRequest" name="fullRequest" />
          <wsdl:output message="tns:greetingResponse"  name="greetingResponseFull" />
        </wsdl:operation>

      </wsdl:portType>


    <wsdl:binding name="HelloServiceSOAP" type="tns:HelloServicePortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

        <wsdl:operation name="simpleGreeting">
          <soap:operation soapAction=""  style="document" />
          <wsdl:input name="shortRequest">
            <soap:body use="literal"/>
          </wsdl:input>
          <wsdl:output name="greetingResponse">
            <soap:body use="literal"/>
          </wsdl:output>
        </wsdl:operation>

       <wsdl:operation name="fullGreeting">
          <soap:operation soapAction=""  style="document" />
          <wsdl:input name="fullRequest">
            <soap:body use="literal"/>
          </wsdl:input>
          <wsdl:output name="greetingResponseFull">
            <soap:body use="literal"/>
          </wsdl:output>
        </wsdl:operation>

      </wsdl:binding>

    <wsdl:service name="ProxyService">
        <wsdl:port binding="tns:HelloServiceSOAP" name="HelloServiceSOAPB">
            <soap:address location="http://localhost:8080/HelloService" />
        </wsdl:port>
    </wsdl:service>     
</wsdl:definitions>

WSDL に問題がある場合は、助けてください。mule cxf:proxy-service で使用すると機能しません。

この WSDL を使用してサービスを公開する Mule Flow を以下に示します。

<flow name="WS_In">
    <http:inbound-endpoint address="http://localhost:8080/HelloService" exchange-pattern="request-response">
        <cxf:proxy-service  wsdlLocation="classpath:globalid3.wsdl" namespace="http://example.org/HelloService" service="ProxyService" />
    </http:inbound-endpoint>        
    <component>             
        <prototype-object class="com.example.ServiceProxy">                                                         
        </prototype-object>
    </component>        
    <echo-component></echo-component>
    <logger level="INFO"        />
</flow>

エラーは次のとおりです。

org.mule.api.lifecycle.LifecycleException: Lifecycle Manager 'WS_In.stage1' phase 'start' does not support phase 'dispose'
at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(AbstractLifecycleManager.java:156)
4

3 に答える 3

3

WSDL に大文字と小文字の問題があります。それ以外の:

  <wsdl:message name="greetingResponse">
    <wsdl:part type="tns:greeting" name="greetings"/>
  </wsdl:message>  

あなたが持っている必要があります:

  <wsdl:message name="greetingResponse">
    <wsdl:part type="tns:Greeting" name="greetings"/>
  </wsdl:message>

これを修正すると、SOAPui から呼び出されたときに正常に動作する Web サービスが次のように生成されます。

<flow name="WS_In">
    <http:inbound-endpoint address="http://localhost:8080/HelloService"
        exchange-pattern="request-response">
        <cxf:proxy-service wsdlLocation="classpath:globalid3.wsdl"
            namespace="http://example.org/HelloService" service="ProxyService" />
    </http:inbound-endpoint>
    <custom-processor class="com.example.ServiceProxy" />
</flow>

メッセージ プロセッサ:

package com.example;

import javax.xml.namespace.QName;

import org.apache.commons.lang.StringEscapeUtils;
import org.mule.api.MuleEvent;
import org.mule.api.MuleException;
import org.mule.api.processor.MessageProcessor;

public class ServiceProxy implements MessageProcessor
{
    private final static QName SIMPLE_GREETING = new QName("http://example.org/HelloService",
        "simpleGreeting");

    public MuleEvent process(final MuleEvent event) throws MuleException
    {
        final QName operation = event.getFlowVariable("cxf_operation");

        if (operation.equals(SIMPLE_GREETING))
        {
            final String lastName = event.getMuleContext()
                .getExpressionLanguage()
                .evaluate("xpath('/lastName').text", event);

            final String responseXml = "<greetings><greet>Hi " + StringEscapeUtils.escapeXml(lastName)
                                       + "</greet></greetings>";

            event.getMessage().setPayload(responseXml);
            return event;
        }

        throw new UnsupportedOperationException(operation.getLocalPart() + " " + operation.getNamespaceURI()
                                                + " " + operation.getPrefix());
    }
}
于 2013-01-04T19:32:56.720 に答える
2

cxf:jaxws-service を使用してこれを行う方法は 1 つありますが、サービス クラスを生成する必要があります。これを行う方法については、こちらをご覧ください 。

その後、非常に簡単な方法でサービスを構成できます。

        <cxf:jaxws-service
            serviceClass="mypackage.webservices.MyServicePortType"
            validationEnabled="false">
        </cxf:jaxws-service>
于 2013-01-04T16:19:30.320 に答える
0

動いている流れは以下の通りです。

<flow name="WS_In">
    <http:inbound-endpoint address="http://localhost:8080/HelloService" exchange-pattern="request-response">
            <cxf:proxy-service  wsdlLocation="classpath:helloservice.wsdl" namespace="http://example.org/HelloService" service="ProxyService" />
        </http:inbound-endpoint>        
        <component>             
            <prototype-object class="com.example.ServiceProxy">     
            </prototype-object>
        </component>        
        <echo-component></echo-component>
        <logger level="INFO"        />
 </flow> 

そして、WSDL は

<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="HelloService"
    targetNamespace="http://example.org/HelloService"
    xmlns:tns="http://example.org/HelloService" 
    xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"  
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

      <wsdl:message name="shortRequest">
        <wsdl:part type="xsd:string" name="lastName"/>
      </wsdl:message>

      <wsdl:message name="fullRequest">
        <wsdl:part type="xsd:string" name="firstName"/>
        <wsdl:part type="xsd:string" name="lastName"/>
      </wsdl:message>

      <wsdl:message name="greetingResponse">
        <wsdl:part type="xsd:string" name="greetings"/>
      </wsdl:message>   


      <wsdl:portType name="HelloServicePortType">

        <wsdl:operation name="simpleGreeting">
          <wsdl:input message="tns:shortRequest" name="shortRequest" />
          <wsdl:output message="tns:greetingResponse" name="greetingResponse" />
        </wsdl:operation>

        <wsdl:operation name="fullGreeting">
          <wsdl:input message="tns:fullRequest" name="fullRequest" />
          <wsdl:output message="tns:greetingResponse"  name="greetingResponseFull" />
        </wsdl:operation>

      </wsdl:portType>


    <wsdl:binding name="HelloServiceSOAP" type="tns:HelloServicePortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

        <wsdl:operation name="simpleGreeting">
          <soap:operation soapAction=""  style="document" />
          <wsdl:input name="shortRequest">
            <soap:body use="literal"/>
          </wsdl:input>
          <wsdl:output name="greetingResponse">
            <soap:body use="literal"/>
          </wsdl:output>
        </wsdl:operation>

       <wsdl:operation name="fullGreeting">
          <soap:operation soapAction=""  style="document" />
          <wsdl:input name="fullRequest">
            <soap:body use="literal"/>
          </wsdl:input>
          <wsdl:output name="greetingResponseFull">
            <soap:body use="literal"/>
          </wsdl:output>
        </wsdl:operation>

      </wsdl:binding>

    <wsdl:service name="ProxyService">
        <wsdl:port binding="tns:HelloServiceSOAP" name="HelloServiceSOAPB">
            <soap:address location="http://localhost:8080/HelloService" />
        </wsdl:port>
    </wsdl:service>

</wsdl:definitions>

皆様のご協力とご支援に感謝いたします。

于 2013-01-04T19:22:27.433 に答える