2012-03-23 21 views
1

ksoap2-androidで複合型をwcfサービスに送信しようとしました。 Basiclyは私がWebサービスから複雑なデータタイプを受け取ることができましたが、私は1を送信しようとすると、私は次のエラーを取得することガイドhttp://seesharpgears.blogspot.de/2010/10/ksoap-android-web-service-tutorial-with.html を追っ:複合型をksoap2-androidからwcfサービスに送信する方法は? wcfサービスの設定方法

a:DeserializationFailed 
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:es. 
The InnerException message was 'Error in line 1 position 373. Element 'http://tempuri.org/:es' contains data from a type that maps to the name 'http://tempuri.org/:EventSeries'. 
The deserializer has no knowledge of any type that maps to this name. 
Consider using a DataContractResolver or add the type corresponding to 'EventSeries' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.'. 
Please see InnerException for more details. 

の質問はどのように私はこの問題を解決することができますです?エラーはエンベロープに返されます。 チュートリアルで説明したようにすべてを行い、複合型を受信すると、サーバー側でエラーが発生すると思いますが、残念ながら私はwcfサービスについて何も知らないのです。 wcfサービスを変更するにはどうすればいいですか?

エラーメッセージで説明したように我々は

[ServiceKnownType(typeof(EventSeries))] 

のようなものを試してみましたが、それは、Webサービスに

メソッドを助けていないが、私は私の添付その

public int InsertEventSeriesForAndroidVIntES(EventSeries es) 
    { 
    ... 
    } 

のように見えますアンドロイドコード、私は何かをねじ込んだ場合。

SoapObject request = new SoapObject("http://tempuri.org/, "InsertEventSeriesForAndroidVIntES"); 

     EventSeries es = new EventSeries(10, "call Test"); 


     PropertyInfo propertyInfo = new PropertyInfo(); 

     propertyInfo.setName("es"); 
     propertyInfo.setNamespace("http://tempuri.org"); 
     propertyInfo.setValue(es); 
     propertyInfo.setType(EventSeries.class); 

     request.addProperty(propertyInfo); 

     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
     envelope.dotNet = true; 

     envelope.setOutputSoapObject(request); 

     envelope.addMapping(request.getNamespace(), "EventSeries", EventSeries.class); 

     HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
     androidHttpTransport.call("http://tempuri.org/IDiversityService/InsertEventSeriesForAndroidVIntES", envelope); 

     SoapPrimitive result = (SoapPrimitive) envelope.getResponse(); 

答えて

3

私は答えが遅れて本当に来て知っているが、うまくいけば他の誰かがそれの恩恵を受ける可能性があります。 以下のチュートリアルhttp://seesharpgears.blogspot.com.es/2010/10/ksoap-android-web-service-tutorial-with.htmlに従って複合型を送信し、同様のエラーが発生しました。 この問題は、ksoapがオブジェクトのマップ方法を知らないため、デフォルトの名前空間によって発生していました。 サービス・インターフェース上で、サービスメソッドに渡されるオブジェクトに、サービス上でそれを設定することで、独自の名前空間を定義してください:[ServiceBehavior(名前空間=のhttp://と

  • 飾るサービスyournamespace.org/)]と
  • 飾るサービスインターフェース:[のServiceContractは、(名前空間= http://yournamespace.org/)]
  • を使用してオブジェクトを飾る:[のDataContract(ネームスペース= http://yournamespace.org /)]

また、 tempuri.orgを独自のyournamespace.orgに置き換えることで、新しい名前空間に合わせるためにクライアントコードを調整してください。 tempuri名前空間を削除する方法の詳細については、次の記事を参照してください。http://blogs.msdn.com/b/endpoint/archive/2011/05/12/how-to-eliminate-tempuri-org-from-your-service-wsdl.aspx

関連する問題