h1

Learning Web Service 6

September 16, 2008

As I was working for setting up Metro web service development environment in Eclipse, I have learned several things I would like to share.

 

The first one is related to literal and wrapped styles. Previously, I wrote we should use soapAction attribute to distinguish one method to another. Actually, it was not so correct. This option is vendor-specific. Some vendor may distinguish one method to another, but others may not. Therefore, we should not use soapAction. When I added a method that has the same parameter with another method, I got the following error from wsimport.

 

“[ERROR] Non unique body parts! In a port, as per BP 1.1 R2710 operations must have unique operation signaure on the wire for successful dispatch. In port wordDictionarySOAPPort, Operations “lookupWord” and “addWord” have the same request body block {http://cgifederal.com/stakehar/ws/metro/tutorial/wordDictionary/word/}word. Try running wsimport with -extension switch, runtime will try to dispatch using SOAPAction”

 

By the way, I think a word “signaure” is typo in wsimport. There are two solutions for this problem. One is to use wrapped style. The other way is to define a new element for the method. Personally, I don’t like wrapped style because JAXB generates unused domain classes. Therefore, I define the new element as I have the same parameters in the new method.

 

The second one is that I learned that you cannot add fault to the method that does not return any response. You will get some error as you do wsimport.

 

Lastly, there is one thing interesting. Generated code in literal and wrapped is quite different. Especially, if some of parameters take input and output, wrapped style generated code will have Holder classes; on the other hand, literal style, there is no such input output parameters because parameters in the element are contained in a generated class. I like literal style in this aspect, too.

 

 Eclipseで、Metroの開発環境をセットアップしている時にいろいろ学ぶ。

 

最初は、LiteralWrappedスタイルに関係している。前にSoapActionアトリビュートは、メソッドを区別するのに使われると書いた。実際、これは正しくない。このオプションは、ベンダーごとに異なっている。あるベンダーはそうするかもしれないが、他のベンダーはそうしないかもしれない。こんなオプションは使わない方がいい。新たなメソッドがすでに定義されているメソッドのパラメターがいっしょの時、次のようなWSIMPORTエラーが見られる。

 

“[ERROR] Non unique body parts! In a port, as per BP 1.1 R2710 operations must have unique operation signaure on the wire for successful dispatch. In port wordDictionarySOAPPort, Operations “lookupWord” and “addWord” have the same request body block {http://cgifederal.com/stakehar/ws/metro/tutorial/wordDictionary/word/}word. Try running wsimport with -extension switch, runtime will try to dispatch using SOAPAction”

 

ところで、signaureは間違いに違いない。二つの解法がある。ひとつはWrappedスタイルを使うこと。もうひとつは、新しいElementを定義すること。個人的には、Wrappedスタイルは好きじゃない。使わないJAXBのクラスが生成されるから。私は、新しいElementを定義する。

 

次は、Responseを返さないWeb Serviceは、Faultを定義することが出来ない。そのようにWSDLで定義すると、WSIMPORTでエラーが発生する。

最後に、面白いことは、LiteralWrappedスタイルでは、生成されるコードにかなり違いがあること。特にパラメターが入出力である場合、Wrappedスタイルでは、Holderクラスが生成される。一方Literalスタイルでは、そのようなクラスは定義されない。なぜなら、パラメターはひとつのElementのクラスに含まれるから。この点でも、Literalスタイルの方が好きだ。

 

2 comments

  1. Hie Take-San,

    For your first solution, wouldn’t it be unfeasible if we had say… 10 operations with the same input structure? That means we have to have 10 different elements that are essentially the same.


  2. Yes, I agree. But I like literal than wrapped.



Leave a Comment