0

複数の独自のデータ型を持つ WCF Web サービスがあります。この構造は機能しません。WSDL を呼び出すことはできますが、メソッドを呼び出そうとすると例外がスローされます。

http://addressへの HTTP 応答の受信中にエラーが発生しました。これは、サービス エンドポイント バインディングが HTTP プロトコルを使用していないことが原因である可能性があります。これは、HTTP 要求コンテキストがサーバーによって中止されたことが原因である可能性もあります (サービスのシャットダウンが原因である可能性があります)。

この記事WCF Web Service error: "Service endpoint binding not using HTTP protocol"? を読みました。、しかし、解決策が見つかりません。設定されていない DataMember を検索<httpRuntime maxRequestLength..>し、web.config で設定しようとしましたが、何も変わりません。私の構造の何が問題になっていますか?

<ServiceContract(Name:="service", Namespace:="http://namespace")>
Public Interface IService1

   <OperationContractAttribute(Action:="http://namespace/methodRequest", name:="method", ReplyAction:="http://namespace/methodResponse")> _
    Function method(input As methodRequest) As methodResponse
End Interface

<MessageContract()>
Public Class methodResponse

    Public result As Object

    <MessageBodyMember(Name:="return", Namespace:="")> 
    Public Property resultP() As Object
        Get
            Return Me.result
        End Get
        Set(value As Object)
            Me.result = value
        End Set
    End Property
End Class

<DataContract()>
Public Class typeArray

    Public typeArrayD As ownType()    

    <DataMember(Name:="value", Order:=1)>
    Public Property value() As ownType()

        Get
            Return typeArrayD
        End Get

        Set(value As ownType ())
            typeArrayD = value
        End Set

    End Property

End Class

<DataContract()>
Public Class ownType
    Private stringValueD As String    

    <DataMember(Name:="stringValue", Order:=1)>
    Public Property stringValue() As String

        Get
            Return stringValueD
        End Get

        Set(value As String)
            stringValueD= value
        End Set

    End Property
End Class

<ServiceBehavior(Namespace:="http://namespace", Name:="service")>
Public Class Service1
    Implements IService1

        Public Function method(input As methodRequest) As methodResponse Implements IService1.method

            Dim result As New methodResponse()
            result.result = New typeArray
            result.result.value = valueOfOwnType

            Return result
     End Function
 End Class
4

1 に答える 1

0

解決:

ServiceKnownType をクラスに追加する必要があります。これで動作します

<ServiceContract(Name:="service", Namespace:="http://namespace")>
<ServiceKnownType(GetType(typeArray))>
<ServiceKnownType(GetType(ownType))>
Public Interface IService1
...
End Interface
于 2015-09-23T12:32:51.653 に答える