0

文字列のリストを返す AXIOM を使用して実装された Axis2 Web サービスがあります。

動作する Java のクライアントのコード スニペットは次のとおりです。

   // * send SOAP message
   sender.fireAndForget( requestObject );

   // * get response
   OMElement reponseObject = sender.sendReceive( requestObject );

    // * iterator for String
    Iterator elementItr = reponseObject.getChildElements();

     while(elementItr.hasNext())
    {
         OMElement element = (OMElement)elementItr.next();

         // * print each message
         System.out.println( element.getText() );
    }

上記のサービスを利用する ac# クライアントを実装する必要があります。

以下のように、単一の String オブジェクトを返す ac# クライアントをテストできました。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HDMClient.hdssWS;

namespace HDMClient
{
    class Program
    {
        static void Main(string[] args)
        {
        HDMClient.hdssWS.StockQuoteServicePortTypeClient client = new hdssWS.StockQuoteServicePortTypeClient("StockQuoteServiceHttpSoap11Endpoint");

        client.update("apple", 1232.123);
        Console.WriteLine(client.getPrice("apple"));
        Console.ReadLine();   
        }
    }
}

app.config のメッセージ タイプは「MTOM」で、WAS の axis2.xml の設定は

    <parameter name="enableMTOM">true</parameter>

単一の String 応答を処理できます。

しかし、上記のように文字列のリストを処理する方法がわかりません。

似たような事例を調べてみました

しかし、私が直面しているケースはないようです。

何か考えはありますか?

4

1 に答える 1

0

何時間もの検索の結果、AXIOM を使用せず、POJO ベースの回避策が見つかりました。

ウェブサービス。

ここに、文字列のリストを返すサービスが来ます。

package samples.quickstart.service.pojo;

import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;

 public class StockQuoteService {
    private HashMap map = new HashMap();

    public List<String> getPrice(String symbol, int number) {
    Double price = (Double) map.get(symbol);

    List<String> retValue = new ArrayList<String>();

    retValue.add("1");
    retValue.add("2");

    return retValue;
}

public void update(String symbol, double price) {
    map.put(symbol, new Double(price));
}
}

そして、.NetプロジェクトのReference.csに、追加しました

[System.ComponentModel.EditorBrowsableAttribute        (System.ComponentModel.EditorBrowsableState.Advanced)]
    HDMClient.hdssWS.getPriceResponse HDMClient.hdssWS.StockQuoteServicePortType.getPrice(HDMClient.hdssWS.getPriceRequest request)
    {
        return base.Channel.getPrice(request);
    }

    public string [] getPrice(string symbol, int number)
    { 
        HDMClient.hdssWS.getPriceRequest inValue = new HDMClient.hdssWS.getPriceRequest();
        inValue.symbol = symbol;
        inValue.number = number;
        HDMClient.hdssWS.getPriceResponse retVal = ((HDMClient.hdssWS.StockQuoteServicePortType)(this)).getPrice(inValue);
        return retVal.@return;
    }

    [System.ComponentModel.EditorBrowsableAttribute    (System.ComponentModel.EditorBrowsableState.Advanced)]
    void HDMClient.hdssWS.StockQuoteServicePortType.update(HDMClient.hdssWS.update request)
    {
        base.Channel.update(request);
    }

    public void update(string symbol, double price)
    {
        HDMClient.hdssWS.update inValue = new HDMClient.hdssWS.update();
        inValue.symbol = symbol;
        inValue.price = price;
        ((HDMClient.hdssWS.StockQuoteServicePortType)(this)).update(inValue);
    }

コードを見ると、C# から Generic で List や ArrayList を使用していません。

戻り値は代わりに文字列配列です。-> ( public string [] getPrice(string symbol, int number) )

そして、C# クライアント コードは以下のようになります。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HDMClient.hdssWS;

namespace HDMClient
{
class Program
{
    static void Main(string[] args)
    {
        HDMClient.hdssWS.StockQuoteServicePortTypeClient client = new hdssWS.StockQuoteServicePortTypeClient("StockQuoteServiceHttpSoap11Endpoint");

        client.update("apple", 1232); 

        string [] result = client.getPrice("apple", 12);

        for (int i = 0; i < result.Length; i++) 
        {
            Console.WriteLine(result[i]);
        }

    }
}
}

そして、コンソールの文字列タイプで1、2を表示することで、期待どおりに機能しました。

.Net クライアントによって消費される Axis2 Web サービスを実装し、

プリミティブデータ型のリストを返すサービスが必要です。私のケースを参照してください。

出力が単なるプリミティブ型で、Generic のようなものではない例がいくつかありますが、

Java でリストします。

于 2013-01-06T11:01:47.017 に答える