0

我正在使用 Mule Studio 创建一个使用公共网络服务http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL&method=GetCityForecastByZIP的流。为了达到同样的效果,我创建了以下配置 xml。

<mule xmlns="http://www.mulesoft.org/schema/mule/core"     xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.2.1" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd 
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
<spring:beans>
    <spring:bean id="Bean" name="Bean" class="javax.xml.bind.JAXBContext" factory-method="newInstance" doc:name="myJAXBCtx">
        <spring:constructor-arg value="com.practice.data"/>
    </spring:bean>
</spring:beans>
<flow name="webservice" doc:name="webservice">
    <file:inbound-endpoint path="D:\MuleStudio\workspace\transformer\ip" moveToDirectory="D:\MuleStudio\workspace\transformer\processed" doc:name="Input Request File">
        <file:filename-regex-filter pattern="^.*\ws.(xml)$" caseSensitive="true"/>
    </file:inbound-endpoint>
    <mulexml:xml-to-object-transformer returnClass="com.practice.data.GetCityForecastByZIP" doc:name="XML to Object">
        <mulexml:alias name="GetCityForecastByZIP" class="com.practice.data.GetCityForecastByZIP"/>
    </mulexml:xml-to-object-transformer>
    <outbound-endpoint address="wsdl-cxf:http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL&amp;method=GetCityForecastByZIP" exchange-pattern="request-response" doc:name="Generic"/>
    <file:outbound-endpoint path="D:\MuleStudio\workspace\transformer\output" outputPattern="ws-response#[function:dateStamp].xml" doc:name="File"/>
</flow>

在 Mule Studio 中运行流程时,出现以下异常:

org.apache.cxf.interceptor.Fault: Marshalling Error: class com.practice.data.GetCityForecastByZIP nor any of its super class is known to this context.

我已经为 GetCityForecastByZIP 提供了正确的注释。参考以下代码:

package com.practice.data;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlRootElement(name="GetCityForecastByZIP",namespace="http://ws.cdyne.com/WeatherWS/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "zip"})
public class GetCityForecastByZIP {

    @XmlElement(name="ZIP",required = true)
    private String zip =  null;

    public GetCityForecastByZIP() {

    }

    public String getZip() {
        return zip;
    }

    public void setZip(String zip) {
        this.zip = zip;
    }
}

有人可以告诉我应该如何纠正这个问题吗?

4

3 回答 3

1

您可以尝试将 zip 作为输入传递给服务(例如,实际的字符串,即 02111,而不是 XML)。

于 2012-06-01T21:04:18.793 回答
0

CXF WSDL 连接器的文档指出:

CXF WSDL 提供程序的一个限制是它不允许您使用非 Java 原语(不是 String、int、double 等的对象)。

GetCityForecastByZIP 返回一个复杂的对象,而不仅仅是一个简单的值,因此您不能使用 CXF WSDL 连接器与此 Web 服务进行交互。

相反,请使用CXF JAX-WS 客户端

于 2012-04-13T16:16:25.813 回答
0

您可以尝试使用 Mule Web 服务使用者组件:-<ws:consumer-config/>吗?
这是参考:- https://developer.mulesoft.com/docs/display/current/Web+Service+Consumer

于 2015-07-21T04:48:16.753 回答