2010-12-09 3 views
5

약간의 문제가 생겼습니다. 문제가 있는지는 확실하지 않지만 조언이 필요합니다.메서드 및 형식을 참조하는 C# webservice에 문제가 발생했습니다.

내가 VS2010에서 교류 #의 웹 서비스를 개발하고 난 서비스를 디버깅 할 때 내가 이제 실제 수업에서 내 코드에서 "VoucherResponse"를 찾고

The XML element 'VoucherResponse' from namespace 'http://test.org/' references a method and a type. Change the method's message name using WebMethodAttribute or change the type's root element using the XmlRootAttribute.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The XML element 'VoucherResponse' from namespace 'test.org' references a method and a type. Change the method's message name using WebMethodAttribute or change the type's root element using the XmlRootAttribute.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

브라우저에서이 오류가 난,이

public class VoucherResponse : AResponse 
{ 
    public Voucher Voucher { get; set; } 
} 

그리고 바우처 객체는 하나 오 지금이

public class Voucher 
{ 
    public string PIN { get; set; } 
    public string Serial { get; set; } 
    public string Batch { get; set; } 
} 

처럼 보인다 f 내 웹 메서드 VoucherResponse를 반환하고이 오류가 반영되고 점검 될 때이 오류가 발생한다고 가정합니다.

누구나 전에 이와 비슷한 문제가 있었습니까? 아니면 아무에게도 이것에 대해 조언 해 줄 수 있습니까?

감사

답변

7

은 분명히, SOAP는 반환 형식과 이름이 같은 방법을 처리 할 수 ​​없습니다. 당신은 오류를 읽고, 그에 따라 행동하여 문제를 해결할 수 :

public class VoucherResponse 
{ 
    [WebMethod(MessageName="TheVoucher")] 
    public Voucher Voucher{get; set;} 
} 
+0

그게 도움이되지 않는 것 같아요, 당신이 제안한 것을 시도하고 같은 오류가 발생합니다 - 편집 : 오히려 그 대신 내 실제 웹 메서드를 VoucherResponse를 반환하고 그것을 사용 .. 감사합니다 –

34

나는 다른 경우 오류를 발생 발견! 여기에 내 코드입니다 :

[WebMethod] 
public CheckUpdateResponse CheckUpdate() 
{ 
... 
} 

확인을 설명해 보자 CheckUpdateResponse 내가 내 코드에 정의 된 구조, CheckUpdate()는 방법이다. 따라서, WSDL .NET에서 메서드 이름에 접미어 Response이 자동으로 추가됩니다. CheckUpdate.

잇함으로써 해결할 수 : 그것은 중복 요소를 발견하고 오류

솔루션을 "WebMethodAttribute ...를 사용하는 방법의 메시지 이름 변경"을 준다? 반환 된 형식의 이름을 CheckUpdateResponse에서 CheckUpdateResult으로 변경 했으므로 이제는 문제가 없습니다.

누군가가 도움이되기를 바랍니다. 나는 이것에 많은 시간을 낭비했다. ...

+1

그냥 이것에 의해 조금이었습니다. 감사! – Ultor

+1

백만 건의 2 건, 나는 생각합니다 ... :) –

+0

옙 ..이게 나를 잡아 냈습니다 –

0

나는 나의 문제에서 같은 문제가 있었다. 내가 개발 한 응용 프로그램은 웹 서비스 클라이언트이므로 WSDL \ Schema를 변경할 권한이 없습니다.

문제는 내가 17 개의 연산을 가진 하나의 웹 서비스를 가지고 있었고 모두 동일한 복합 유형을 반환한다는 것이 었습니다. 반환 유형의 직렬화 해제로 인해 언급 된 오류가있었습니다 .Net은 각 반환 유형을 래핑하기 때문에 출력 및 시리얼 라이저가 던지고 오류 :

The XML element 'XYZ' from namespace 'ABC' references a method and a type. Change the method's message name using WebMethodAttribute or change the type's root element using the XmlRootAttribute. 

솔루션 : 내가 Reference.cs 파일을 열어 모든 wappered 반환 형식이 생성 된 클래스를 제거하고 단 하나의 유지 은 다음의 클래스 이름은 일반적으로 변경 수술과 관련없는, 그것은 나를 위해 일했다.

관련 문제