0

Mule Studio を使用して、パブリック Web サービス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 を入力としてサービスに渡すだけです (XML の代わりに実際の文字列、つまり 02111 など)。

于 2012-06-01T21:04:18.793 に答える
0

CXF WSDL コネクタのドキュメントには、次のように記載されています。

CXF WSDL プロバイダーの 1 つの制限は、Java 以外のプリミティブ (String、int、double などではないオブジェクト) を使用できないことです。

GetCityForecastByZIP は単なる値ではなく複雑なオブジェクトを返すため、CXF WSDL コネクタを使用してこの Web サービスと対話することはできません。

代わりに、CXF JAX-WS クライアントを使用してください。

于 2012-04-13T16:16:25.813 に答える