2009-07-13 18 views
1

別の.NETアプリケーションから呼び出されたときに.NET WCF Webサービスがうまく機能しています。今私はサービスをテストするJavaクライアントを構築しようとしていましたが、メソッドの1つが機能しません。JavaクライアントからWCF Webサービスへのオブジェクト、エラー逆シリアル化

更新の一覧を送信しようとしました。複合型は次のとおりです。

<xs:complexType name="ArrayOfRegisterUpdate"> 
    <xs:sequence> 
     <xs:element minOccurs="0" maxOccurs="unbounded" name="OneUpdateRegister" 
        nillable="true" type="tns:OneUpdateRegister" /> 
    </xs:sequence> 
</xs:complexType> 
<xs:element name="ArrayOfRegisterUpdate" nillable="true" 
    type="tns:ArrayOfRegisterUpdate" /> 
<xs:complexType name="OneUpdateRegister"> 
    <xs:sequence> 
     <xs:element minOccurs="0" name="Field" type="tns:RegisterField" /> 
     <xs:element minOccurs="0" name="Value" nillable="true" type="xs:anyType" /> 
    </xs:sequence> 
</xs:complexType> 
<xs:element name="OneUpdateRegister" nillable="true" type="tns:OneUpdateRegister" /> 

私のJavaプロキシは、予想通り、私は、「バリュー」に任意のオブジェクトを挿入できます(これは文字列、int型または日付時刻することができます)。しかし、文字列を入力すると、次の例外が発生します。

The formatter threw an exception while trying to deserialize the message: 
There was an error while trying to deserialize parameter http://tempuri.org/:updates. 
The InnerException message was 'There was an error deserializing the object of type 
System.Collections.Generic.List`1 
[[xxx.xxx.OneUpdateRegister, XXx.XXx, Version=1.0.0.0, Culture=neutral, `PublicKeyToken=null]]. 
The value 'John' cannot be parsed as the type 'Guid.'. Please see InnerException for more details. 

Webメソッドは呼び出されません。私はタイプ 'Guid'がこれと何をしなければならないのか分かりません、単純なタイプのxsdでこのタイプを見ることができます。

他に有用な情報を教えてください。ありがとうございました。

+0

?例外(クライアントまたはサーバー)はどこから来ていますか? FieldまたはValueプロパティに "John"の値を設定しようとしていますか?リスト(Of T)の代わりにオブジェクトの配列を使用しようとしましたか? –

+0

複合型コードはサーバーから提供されます。そのメソッドを呼び出そうとすると、例外がクライアントに表示されます。私は "ジョン"の値をValueプロパティに入れようとしています。 配列の代わりにリスト(Of T)を使用することは必須ですが、なぜ私に質問していませんが、それは私たちの仕事です。 –

答えて

0

nullを指定するか、DateTime(Javaのカレンダー)を使用すると問題はありません。文字列だけに問題があるようです。 一方、intは文字列として送信され、同じ問題が発生します。

1

XMLスキーマのこの部分はどこから来たのですか?

[OperationContract]を含む、呼び出されている操作の署名を投稿できますか?サービス契約と同じです。

呼び出しているJavaプロキシのシグニチャは何ですか。

私はこのスキーマがあなたが望まないかもしれないXMLを検証することができると懸念しています。たとえば、フィールド、値、値のシーケンスを持つことができることに気付きましたか?

「Guid」がどこから来ているのかは説明していません。

0

私は恐怖です。私は本当の専門家ではありません。私は、これは、サーバー側では、のために私に尋ねたものです推測:

[System.ServiceModel.ServiceContractAttribute(Namespace="http://xx.es/ServiceName/", ConfigurationName="ServiceName.InterfaceName")] 
public interface InterfaceName{ 

    .... 

    [System.ServiceModel.OperationContractAttribute(Action="http://xx.es/ServiceName/InterfaceName/UpdateRegister", ReplyAction="http://xx.es/ServiceName/InterfaceName/UpdateRegisterRes" + 
     "ponse")] 
    package.UpdateRegisterReturn UpdateRegister(string user, string password, int id1, int id2, System.Collections.Generic.List<package.OneUpdateRegister> updates); 

     .... 
    } 

私の最初のエントリからXMLスキーマファイルから、サーバーから来ている。これは私の自動生成の署名である

をServiceName.xsd Javaプロキシ:

public es.xx.UpdateRegisterReturn updateRegister(java.lang.String user, java.lang.String password, java.lang.Integer id1, java.lang.Integer id2, es.xx.OneUpdateRegister[] updates) throws java.rmi.RemoteException{ 

私はそれがこのように自動生成された場合でも、それは日付とヌルで動作しても、リストのように、このJavaのパラメータを強制する必要がありますか?

このファイル(ServiceName1.xsdは)私にGUIDタイプを見つけることができます全体のサーバソリューションで唯一の場所である:

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="anyType" nillable="true" type="xs:anyType" /> 
    <xs:element name="anyURI" nillable="true" type="xs:anyURI" /> 
    <xs:element name="base64Binary" nillable="true" type="xs:base64Binary" /> 
    <xs:element name="boolean" nillable="true" type="xs:boolean" /> 
    <xs:element name="byte" nillable="true" type="xs:byte" /> 
    <xs:element name="dateTime" nillable="true" type="xs:dateTime" /> 
    <xs:element name="decimal" nillable="true" type="xs:decimal" /> 
    <xs:element name="double" nillable="true" type="xs:double" /> 
    <xs:element name="float" nillable="true" type="xs:float" /> 
    <xs:element name="int" nillable="true" type="xs:int" /> 
    <xs:element name="long" nillable="true" type="xs:long" /> 
    <xs:element name="QName" nillable="true" type="xs:QName" /> 
    <xs:element name="short" nillable="true" type="xs:short" /> 
    <xs:element name="string" nillable="true" type="xs:string" /> 
    <xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte" /> 
    <xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt" /> 
    <xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong" /> 
    <xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort" /> 
    <xs:element name="char" nillable="true" type="tns:char" /> 
    <xs:simpleType name="char"> 
    <xs:restriction base="xs:int" /> 
    </xs:simpleType> 
    <xs:element name="duration" nillable="true" type="tns:duration" /> 
    <xs:simpleType name="duration"> 
    <xs:restriction base="xs:duration"> 
     <xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?" /> 
     <xs:minInclusive value="-P10675199DT2H48M5.4775808S" /> 
     <xs:maxInclusive value="P10675199DT2H48M5.4775807S" /> 
    </xs:restriction> 
    </xs:simpleType> 
    <xs:element name="guid" nillable="true" type="tns:guid" /> 
    <xs:simpleType name="guid"> 
    <xs:restriction base="xs:string"> 
     <xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}" /> 
    </xs:restriction> 
    </xs:simpleType> 
    <xs:attribute name="FactoryType" type="xs:QName" /> 
</xs:schema> 

私はそれが自動生成された汎用的なファイルだと思います。

+0

ありがとうございます。そのエラーメッセージがどこから来ているのかはわかりません。 .NET例外のようには見えませんが、.NETの型とアセンブリについて言及しています。それが例外であれば、すべてを投稿できますか?例外をキャッチし、ex.ToString()を送信します。サービスに送信されているXMLを投稿することもできます。また、私はRegisterField型の定義をしたいと思います。 –

0

申し訳ありませんが、私はちょうどxsdが.netソリューションのテストクライアントから提供されていることに気付きました!とにかく、彼らは手がかりを与えるかもしれません。

これらは、Webサービスから実際のファイルです:

[ServiceContract(Namespace = Constants.PublicNamespace)] 
    public interface InterfaceName 
    { 

     ///<summary> 
     ///</summary> 
     ///<param name="user"></param> 
     ///<param name="password"></param> 
     ///<param name="id1"></param> 
     ///<param name="id2"></param> 
     ///<param name="updates"></param> 
     ///<returns></returns> 
     [OperationContract] 
     UpdateRegisterReturn UpdateRegister(
      string user, 
      string password, 
      int id1, 
      int id2, 
      List<OneUpdateRegister> updates); 

     ... {other methods working just fine}  
    } 
} 

そして、これはクラスOneUpdateRegisterです:複合型コードは(クライアントまたはサーバ)から来ている

 ///<summary> 
    ///</summary> 
    [DataContract(Namespace = Constants.PublicNamespace)] 
    public sealed class OneUpdateRegister 
    { 
     ///<summary> 
     ///</summary> 
     [DataMember] 
     public RegisterField Field { get; set; } 

     ///<summary> 
     ///</summary> 
     [DataMember] 
     public object Value{ get; set; } // this is the problematic data member! 
    } 
関連する問題