1.プロジェクト>Web 参照の追加
URL: http://localhost:8080/axis/services/list?wsdl [参照の追加]を押す
2.コマンドプロンプトを立ち上げる
> wsdl http://localhost:8080/axis/services/list?wsdl
3.生成された PatientListService?.cs をプロジェクトにコピー
Java側の窓口が複数のクラスに分かれている場合、C#にWebReference?が複数できる。 このとき、Java側では同じBeanクラスであっても、 WebReference1で受け取ったBeanをWebReference2で使用することができない。 C#内部でWebReference1で取得したBeanをコピーして、 WebReference2用のBeanを作成する必要がある。
Java側でエラーがおきていないのにもかかわらず、クライアントに届かない場合、 axis内部でエラーが起きている可能性がある。 log4jでaxisのエラーをDEBUGレベルで出力するようにするとわかるかも。 (ERRORレベルだとでない・・・)
log4j.logger.org.apache.axis=debug, axis log4j.additivity.org.apache.axis = false # axis用 log4j.appender.axis = org.apache.log4j.DailyRollingFileAppender log4j.appender.axis.File = /DATA/log/axis.log log4j.appender.axis.Append = true log4j.appender.axis.DatePattern = yyyy-MM-dd'.txt' log4j.appender.axis.layout = org.apache.log4j.PatternLayout log4j.appender.axis.layout.ConversionPattern = %d [%t] %.5p '%m' %F%n
java -classpath axis.jar;commons-discovery-0.2.jar;commons-logging-1.0.4.jar; jaxrpc.jar;log4j-1.2.8.jar;saaj.jar;wsdl4j-1.5.1.jar org.apache.axis.utils.tcpmon
自動生成されたスタブ(Reference.cs)のWseの方を使わないとダメ public partial class Service : System.Web.Services.Protocols.SoapHttpClientProtocol { → public partial class ServiceWse : Microsoft.Web.Services3.WebServicesClientProtocol
MTOM用のWSDLが正式に決まってないからか、サービスの自動生成が上手く出来ない。 そのため、以下の手順でスタブを変更する必要がある。 VisualStudio2005+WSE3.0で確認。
1.プロジェクト右クリック -> WSE Settings 3.0 -> General : Enable this project...=Checked Messaging : Client Mode=On, Server Mode=optional, MaxMimeParts=64 2. Web参照の追加でWSDLを読み込む 3.自動生成されたスタブ(Reference.cs)の上のほうを変更 public partial class Service : System.Web.Services.Protocols.SoapHttpClientProtocol { → public partial class ServiceWse : Microsoft.Web.Services3.WebServicesClientProtocol コンストラクタも Service -> ServiceWse にしておく 4.参照設定で、Microsoft.Web.Services3 を追加
rpc/encoding
<soap:envelope> <soap:body> <myMethod> <x xsi:type="xsd:int">5</x> <y xsi:type="xsd:float">5.0</y> </myMethod> </soap:body> </soap:envelope>
rpc/literal
<soap:envelope> <soap:body> <myMethod> <x>5</x> <y>5.0</y> </myMethod> </soap:body> </soap:envelope>
Document/literal
<soap:envelope> <soap:body> <xElement>5</xElement> <yElement>5.0</yElement> </soap:body> </soap:envelope>
Document/literal wrapped
<soap:envelope> <soap:body> <myMethod> <x>5</x> <y>5.0</y> </myMethod> </soap:body> </soap:envelope>
http://www.ws-i.org/deliverables/workinggroup.aspx?wg=testingtools でゲットできるツールを使用する場合、送信するメッセージにXML宣言部(<?xml ...?>)がないと動かない。 また、サポートしているBasicProfile?が古いので注意!multipartとか無理だった。
wrapしたい場合
public class Test { public string[] element1; }
<TEST> <element1> <string /> <string /> </element1> </TEST>
wrapしたくない場合
public class Test { [System.Xml.Serialization.XmlElementAttribute(IsNullable = true)] public string[] element1; }
<TEST> <element1 /> <element1 /> </TEST>
[WebMethod] [return: System.Xml.Serialization.XmlElementAttribute(IsNullable = true)] public string test([System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]string param1) { return param1; }
[WebMethod] [return: System.Xml.Serialization.XmlAnyElementAttribute()] public XmlElement testAny([System.Xml.Serialization.XmlAnyElementAttribute()]XmlElement Any) { return Any; }
Linux
サーバ構築
Windows
Java
Program