WSO2 AS 5.1.0 でマッシュアップを作成しようとしています。単純な HelloWorld サービスを正常に作成できましたが、他のサービスをそれに統合しようとすると、エラーが発生します。
これは私の HelloWorld サービスです。
this.documentation = "This is a test Hello World service";
system.include("HelloStub.js");
hello.documentation = "say hello"
hello.inputTypes = {"user": "string"}
hello.outputType = "string";
function hello(user){
try{
var response = services["admin/testmashup"].operations["sayMyName"](user);
}catch(e){
return "Danger, Robinson! " + e.toString()
}
return "Hello, there! " + response;
}
function whoAreYou(){
try{
var response = services["admin/testmashup"].operations["toString"]();
}catch(e){
return "Danger, Robinson! " + e.toString()
}
return "Hello! " + response;
}
そしてこれがadmin/testmashup
サービス
this.serviceName = "testmashup";
this.documentation = "Test mashup service" ;
toString.documentation = "say something" ;
toString.inputTypes = { /* no arguments */ };
toString.outputType = "string";
function toString()
{
return "Hi, my name is testmashup";
}
sayMyName.documentation = "Make me feel happy";
sayMyName.inputTypes = {"myName":"string"};
sayMyName.outputType = "string";
function sayMyName(myName){
return "Your very beautiful name is " + myName;
}
admin/testmashup
サービスを呼び出すと、期待どおりに機能することに注意する必要があります。
このファイルHelloStub.js
は、WSO2 Applicanton Server によって生成される Javascript (E4X) スタブです。
whoAreYou
引数のない操作をテストすると、次の応答が返されます。
<ws:whoAreYouResponse xmlns:ws="http://services.mashup.wso2.org/helloWorld?xsd">
<return xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:js="http://www.wso2.org/ns/jstype" js:type="string" xsi:type="xs:string">Hello! <ws:toStringResponse xmlns:ws="http://services.mashup.wso2.org/testmashup?xsd"><return>Hi, my name is testmashup</return></ws:toStringResponse></return>
</ws:whoAreYouResponse>
Hi, my name is testmashup
エンコードされた応答内にテキストが表示されます。しかしhello
、次のxmlを使用して を呼び出そうとすると:
<body>
<p:hello xmlns:p="http://services.mashup.wso2.org/helloWorld?xsd">
<!--Exactly 1 occurrence-->
<user>John</user>
</p:hello>
</body>
次のエラーが表示されます。
<ws:helloResponse xmlns:ws="http://services.mashup.wso2.org/helloWorld?xsd">
<return>Danger, Robinson! org.wso2.carbon.CarbonException: Invalid input for the payload in WSRequest Hostobject : John</return>
</ws:helloResponse>
ここ数日間、これを機能させようとしましたが、あちこちで答えを探しましたが、見つけられないようです。公式ドキュメントには、1 つ以上の引数を持つ操作を持つ外部 Web サービスのスタブを使用した例は記載されていません。
また、可能であれば、JavaScript マッシュアップから REST-JSON サービスを利用する方法を知りたいです。
何か案は?