2012-03-20 1 views
2

SOAP 웹 서비스에 객체를 보낼 수 없습니다 : 내가이 개체를 변환하는 방법 내부나는 방법과 비누 웹 서비스가

string startReaction(object reaction); 

을 실제 유형입니다 :

Reaction reactionObj = (Reaction)reaction; 
... 

내가 가지고있는 동일한 Reaction 클래스를 양식 프로젝트 (이 창은이 ws를 호출해야합니다)에 있습니다. 여기서 Reaction 객체 인스턴스를 만들고 데이터로 채우고 웹 서비스로 보내려고합니다.

string data = webserviceReference1.startReaction(reaction); 

가 나는 또한 시도 :

string data = webserviceReference1.startReaction(reaction as object); 

하지만 아무것도. 는 그럼 난 반응 클래스에이 특성을 추가하려고 :

[XmlInclude(typeof(object))] 
public class Reaction{... 

하지만 아무것도. 내가 할 오류 :

[WebMethod] 
[XmlInclude(typeof(Reaction))] 
[XmlInclude(typeof(Foo))] 
[XmlInclude(typeof(Bar))] 
// ... the list goes on with all possible types that you might want to pass to this method 
// since you used object as argument you need to explicitly say which types are allowed here 
public string startReaction(object reaction) 
{ 
    ... 
} 

당신은에 같은 클래스를 재정의해서는 안 : 클라이언트가 그것에 대해 알 수 있도록

There was an error generating the XML document. :: System.InvalidOperationException: The type Demo.Form1+Reaction was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. 
+0

왜 안 되죠? string startReaction (반응 반응); '? –

답변

4

당신은 sevrice의 메타 데이터에 Reaction 클래스를 노출해야 클라이언트가 작동하지 않기 때문입니다. 서버는 그것을 직렬화하는 방법을 모른다. 정확한 방법은 웹 서비스가 모든 알려진 유형을 WSDL에 노출시켜 클라이언트에 강력한 형식의 프록시를 생성 할 때 모든 유형을 가져오고 서비스를 호출 할 수 있도록하는 것입니다.

관련 문제