请在WSDL上提出建议 [英] Please advise on the WSDL

查看:75
本文介绍了请在WSDL上提出建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了WSDL来创建问候服务。下面是WSDL。

I have created a WSDL to create a greeting service. Given below is the WSDL.

我正在使用wsdl来创建生成器,并使用mule中的cxf:proxy-service公开Web服务。

I am using thsi wsdl to create a generate and expose a web-service using the cxf:proxy-service in mule.

这给了我错误。

请查看并帮助我理解此WSDL的问题是什么。

Please review and help me undertand what is the problem with this 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中有问题,请帮助我。
当我在c子cxf:proxy-service中使用它时,它不起作用。

Please help me if there is something wrong in my WSDL. It is not working when I use it in mule cxf:proxy-service.

下面给出了使用此WSDL公开服务的M子流。

FGiven below si the Mule Flow which is using this WSDL to expose service.

<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)


推荐答案

有一个大小写WSDL中的问题。代替:

There is a casing issue in your WSDL. Instead of:

  <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服务:

With this fixed, the following produces a web service that works fine when called from SOAPui:

<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());
    }
}

这篇关于请在WSDL上提出建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆