2010-11-29 13 views
1

私は、既存のWSDLから.NET SOAP Webサービス(svcutilを使用)を生成しようとしています。 WSDLは、次の情報が含まれています正しいWSDLを再生成するようにsvcutil生成コードを構成するにはどうすればよいですか?

<types> 
<xsd:schema> 
<!-- ... --> 
<xsd:complexType name="DoStuffType"> 
    <xsd:sequence> 
    <xsd:element name="..." type="..." /> 
    </xsd:sequence> 
</xsd:complexType> 
<xsd:complexType name="DoStuffResponseType"> 
    <xsd:sequence> 
    <xsd:element name="..." type="..." /> 
    </xsd:sequence> 
</xsd:complexType> 
<xsd:element name="DoStuff" type="tns:DoStuffType" /> 
<xsd:element name="DoStuffResponse" type="tns:DoStuffResponseType" /> 
</xsd:schema> 
</types> 

<message name="DoStuffSoapIn"> 
    <part name="messagePart" element="tns:DoStuff" /> 
</message> 
<message name="DoStuffSoapOut"> 
    <part name="messagePart" element="tns:DoStuffResponse" /> 
</message> 

<portType name="ASoapService"> 
    <operation name="DoStuff"> 
    <input message="tns:DoStuffSoapIn" /> 
    <output message="tns:DoStuffSoapOut" /> 
    </operation> 
</portType> 

生成されたコードをコンパイルして、[OK]を展開し、それがDoStuff動作の詳細が含まれていない生成WSDL。

私は[OperationContract(ReplyAction = "*")]属性を削除した場合、私はサービスから次のエラーを取得する:

System.InvalidOperationException: An exception was thrown in a call to a 
    WSDL export extension: 
System.ServiceModel.Description.DataContractSerializerOperationBehavior 
    contract: http://example.com/services:ASoapService----> 
System.InvalidOperationException: Top level XML element with name 
    DoStuffResponse in namespace http://example.com/services cannot reference 
    http://schemas.datacontract.org/2004/07/Generated:DoStuffResponseType type 
    because it already references a different type 
    (http://example.com/services:DoStuffResponseType). 
Use a different operation name or MessageBodyMemberAttribute to specify a 
    different name for the Message or Message parts. 

私は、レスポンスコードから[MessageContract(IsWrapped="false")]属性を削除した場合、私は次のエラーを取得:

System.InvalidOperationException: The operation 'DoStuff' could not be loaded 
    because it has a parameter or return type of type 
    System.ServiceModel.Channels.Message or a type that has 
    MessageContractAttribute and other parameters of different types. When using 
    System.ServiceModel.Channels.Message or types with MessageContractAttribute, 
    the method must not use any other types of parameters. 

さらに、要求コードから[MessageContract(IsWrapped="false")]属性を削除すると、すべてのエラーがなくなりますが、(おそらくおそらく)要求に<request>要素のラッピングが必要になります。

正しいWSDLを再生成できるようにするには、生成されたコードに何をする必要がありますか?

+0

名前空間をよく見てください。間違った名前空間を参照しているようです。 –

+0

それは確かに最初のエラーが示唆していることですが、私はコードで何か間違って見ることはできません。 'http:// schemas.datacontract.org'への明示的な参照はありません。アイデア? –

答えて

0

similar questionの回答によれば、解決策はReplyAction = "*"部分を削除することですが、OperationContract属性を保持することです。

関連する問題