2017-05-02 16 views
0

このWSDLは、IISサーバー内のインバウンド/アウトバウンドメッセージに使用されることになっています。私は "wsdl thefile.wsdl/l:VB"を使って.vbファイルを生成しましたが、今私は何をすべきか分かりません。私はインバウンドメッセージを保存するメソッドをコーディングすることになっています。WSDLをASMXに実装する方法

<?xml version="1.0" encoding="utf-8"?> 
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.softwriters.com/fwhl7/1.0/" 
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://www.softwriters.com/fwhl7/1.0/" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> 
<wsdl:types> 
<s:schema elementFormDefault="qualified" targetNamespace="http://www.softwriters.com/fwhl7/1.0/"> 
<s:element name="SendMessage"> 
<s:complexType> 
<s:sequence> 
<s:element minOccurs="0" maxOccurs="1" name="userId" type="s:string" /> 
<s:element minOccurs="0" maxOccurs="1" name="passwordDigest" type="s:base64Binary" /> 
<s:element minOccurs="0" maxOccurs="1" name="nonce" type="s:string" /> 
<s:element minOccurs="1" maxOccurs="1" name="ts" type="s:dateTime" /> 
<s:element minOccurs="0" maxOccurs="1" name="message" type="s:base64Binary" /> 
</s:sequence> 
</s:complexType> 
</s:element> 
<s:element name="SendMessageResponse"> 
<s:complexType> 
<s:sequence> 
<s:element minOccurs="0" maxOccurs="1" name="SendMessageResult" type="s:base64Binary" /> 
</s:sequence> 
</s:complexType> 
</s:element> 
</s:schema> 
</wsdl:types> 
<wsdl:message name="SendMessageSoapIn"> 
<wsdl:part name="parameters" element="tns:SendMessage" /> 
</wsdl:message> 
<wsdl:message name="SendMessageSoapOut"> 
<wsdl:part name="parameters" element="tns:SendMessageResponse" /> 
</wsdl:message> 
<wsdl:portType name="FwHL7Soap"> 
<wsdl:operation name="SendMessage"> 
<wsdl:input message="tns:SendMessageSoapIn" /> 
<wsdl:output message="tns:SendMessageSoapOut" /> 
</wsdl:operation> 
</wsdl:portType> 
<wsdl:binding name="FwHL7Soap" type="tns:FwHL7Soap"> 
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
<wsdl:operation name="SendMessage"> 
<soap:operation soapAction="http://www.softwriters.com/fwhl7/1.0/SendMessage" style="document" /> 
<wsdl:input> 
<soap:body use="literal" /> 
</wsdl:input> 
    <wsdl:output> 
<soap:body use="literal" /> 
</wsdl:output> 
</wsdl:operation> 
</wsdl:binding> 
<wsdl:binding name="FwHL7Soap12" type="tns:FwHL7Soap"> 
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
<wsdl:operation name="SendMessage"> 
<soap12:operation soapAction="http://www.softwriters.com/fwhl7/1.0/SendMessage" style="document" /> 
<wsdl:input> 
<soap12:body use="literal" /> 
</wsdl:input> 
<wsdl:output> 
<soap12:body use="literal" /> 
</wsdl:output> 
</wsdl:operation> 
</wsdl:binding> 
<wsdl:service name="FwHL7"> 
<wsdl:port name="FwHL7Soap" binding="tns:FwHL7Soap"> 
<soap:address location="http://localhost:53012/FwHL7.asmx" /> 
</wsdl:port> 
<wsdl:port name="FwHL7Soap12" binding="tns:FwHL7Soap12"> 
<soap12:address location="http://localhost:53012/FwHL7.asmx" /> 
</wsdl:port> 
</wsdl:service> 
</wsdl:definitions> 

私は新しいASP.NET Webサービスプロジェクトを作成し、WSDLをサービス参照に追加し、生成された.vbをインポートしました。私はプロジェクト内でASMXファイルを作成しましたが、そこからどこに行くのかはわかりません。

Option Strict Off 
Option Explicit On 
'------------------------------------------------------------------------------ 
' <auto-generated> 
'  This code was generated by a tool. 
'  Runtime Version:4.0.30319.42000 
' 
'  Changes to this file may cause incorrect behavior and will be lost if 
'  the code is regenerated. 
' </auto-generated> 
'------------------------------------------------------------------------------ 

Imports System.Web.Services 

<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"), 
System.ServiceModel.ServiceContractAttribute([Namespace]:="http://www.softwriters.com/fwhl7/1.0/", ConfigurationName:="FwHL7Soap")> 
Public Interface FwHL7Soap 

    'CODEGEN: Generating message contract since element name userId from namespace http://www.softwriters.com/fwhl7/1.0/ is not marked nillable 
    <System.ServiceModel.OperationContractAttribute(Action:="http://www.softwriters.com/fwhl7/1.0/SendMessage", ReplyAction:="*")> 
    Function SendMessage(ByVal request As SendMessageRequest) As SendMessageResponse 

    <System.ServiceModel.OperationContractAttribute(Action:="http://www.softwriters.com/fwhl7/1.0/SendMessage", ReplyAction:="*")> 
    Function SendMessageAsync(ByVal request As SendMessageRequest) As System.Threading.Tasks.Task(Of SendMessageResponse) 
End Interface 

<System.Diagnostics.DebuggerStepThroughAttribute(), 
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"), 
System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced), 
System.ServiceModel.MessageContractAttribute(IsWrapped:=False)> 
Partial Public Class SendMessageRequest 

    <System.ServiceModel.MessageBodyMemberAttribute(Name:="SendMessage", [Namespace]:="http://www.softwriters.com/fwhl7/1.0/", Order:=0)> 
    Public Body As SendMessageRequestBody 

    Public Sub New() 
     MyBase.New 
    End Sub 

    Public Sub New(ByVal Body As SendMessageRequestBody) 
     MyBase.New 
     Me.Body = Body 
    End Sub 
End Class 

<System.Diagnostics.DebuggerStepThroughAttribute(), 
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"), 
System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced), 
System.Runtime.Serialization.DataContractAttribute([Namespace]:="http://www.softwriters.com/fwhl7/1.0/")> 
Partial Public Class SendMessageRequestBody 

    <System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=False, Order:=0)> 
    Public userId As String 

    <System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=False, Order:=1)> 
    Public passwordDigest() As Byte 

    <System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=False, Order:=2)> 
    Public nonce As String 

    <System.Runtime.Serialization.DataMemberAttribute(Order:=3)> 
    Public ts As Date 

    <System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=False, Order:=4)> 
    Public message() As Byte 

    Public Sub New() 
     MyBase.New 
    End Sub 

    Public Sub New(ByVal userId As String, ByVal passwordDigest() As Byte, ByVal nonce As String, ByVal ts As Date, ByVal message() As Byte) 
     MyBase.New 
     Me.userId = userId 
     Me.passwordDigest = passwordDigest 
     Me.nonce = nonce 
     Me.ts = ts 
     Me.message = message 
    End Sub 
End Class 

<System.Diagnostics.DebuggerStepThroughAttribute(), 
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"), 
System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced), 
System.ServiceModel.MessageContractAttribute(IsWrapped:=False)> 
Partial Public Class SendMessageResponse 

    <System.ServiceModel.MessageBodyMemberAttribute(Name:="SendMessageResponse", [Namespace]:="http://www.softwriters.com/fwhl7/1.0/", Order:=0)> 
    Public Body As SendMessageResponseBody 

    Public Sub New() 
     MyBase.New 
    End Sub 

    Public Sub New(ByVal Body As SendMessageResponseBody) 
     MyBase.New 
     Me.Body = Body 

    End Sub 
End Class 

<System.Diagnostics.DebuggerStepThroughAttribute(), 
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"), 
System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced), 
System.Runtime.Serialization.DataContractAttribute([Namespace]:="http://www.softwriters.com/fwhl7/1.0/")> 
Partial Public Class SendMessageResponseBody 

    <System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue:=False, Order:=0)> 
    Public SendMessageResult() As Byte 

    Public Sub New() 
     MyBase.New 
    End Sub 

    Public Sub New(ByVal SendMessageResult() As Byte) 
     MyBase.New 
     Me.SendMessageResult = SendMessageResult 
    End Sub 
End Class 

<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")> 
Public Interface FwHL7SoapChannel 
    Inherits FwHL7Soap, System.ServiceModel.IClientChannel 
End Interface 

<System.Diagnostics.DebuggerStepThroughAttribute(), 
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")> 
Partial Public Class FwHL7SoapClient 
    Inherits System.ServiceModel.ClientBase(Of FwHL7Soap) 
    Implements FwHL7Soap 

    Public Sub New() 
     MyBase.New 
    End Sub 

    Public Sub New(ByVal endpointConfigurationName As String) 
     MyBase.New(endpointConfigurationName) 
    End Sub 

    Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String) 
     MyBase.New(endpointConfigurationName, remoteAddress) 
    End Sub 

    Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress) 
     MyBase.New(endpointConfigurationName, remoteAddress) 
    End Sub 

    Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress) 
     MyBase.New(binding, remoteAddress) 
    End Sub 

    <System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)> 
    Function FwHL7Soap_SendMessage(ByVal request As SendMessageRequest) As SendMessageResponse Implements FwHL7Soap.SendMessage 
     Return MyBase.Channel.SendMessage(request) 
    End Function 

    <WebMethod()> 
    Public Function SendMessage(ByVal userId As String, ByVal passwordDigest() As Byte, ByVal nonce As String, ByVal ts As Date, ByVal message() As Byte) As Byte() 
     Dim inValue As SendMessageRequest = New SendMessageRequest() 
     inValue.Body = New SendMessageRequestBody() 
     inValue.Body.userId = userId 
     inValue.Body.passwordDigest = passwordDigest 
     inValue.Body.nonce = nonce 
     inValue.Body.ts = ts 
     inValue.Body.message = message 
     Dim retVal As SendMessageResponse = CType(Me, FwHL7Soap).SendMessage(inValue) 
     Return retVal.Body.SendMessageResult 
    End Function 

    <WebMethod()> 
    <System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)> 
    Function FwHL7Soap_SendMessageAsync(ByVal request As SendMessageRequest) As System.Threading.Tasks.Task(Of SendMessageResponse) Implements FwHL7Soap.SendMessageAsync 
     Return MyBase.Channel.SendMessageAsync(request) 
    End Function 

    <WebMethod()> 
    Public Function SendMessageAsync(ByVal userId As String, ByVal passwordDigest() As Byte, ByVal nonce As String, ByVal ts As Date, ByVal message() As Byte) As System.Threading.Tasks.Task(Of SendMessageResponse) 
     Dim inValue As SendMessageRequest = New SendMessageRequest() 
     inValue.Body = New SendMessageRequestBody() 
     inValue.Body.userId = userId 
     inValue.Body.passwordDigest = passwordDigest 
     inValue.Body.nonce = nonce 
     inValue.Body.ts = ts 
     inValue.Body.message = message 
     Return CType(Me, FwHL7Soap).SendMessageAsync(inValue) 
    End Function 
End Class 

答えて

2

私は明確化を求めるためにコメントをしたいが、私はそれを行うことができるという2評判短いです:インターフェースを見て、私は私が適用可能な方法を()WebMethod属性を追加する必要がありますと仮定しています。

代わりに、私はいくつか前提をします。

仮定1 - wsdlが生成されたWebサービスにアクセスできません。

仮定2 - Webサービスを呼び出すクライアントを構築しており、クライアントを介してすべての呼び出しを追跡します。

仮定3 - あなたはVisual Studioを使用しています。

私の前提に間違いがある場合は、お気軽にコメントしてください。あなたの質問に一層合致するように私の回答を編集します。

これで、wsdlから生成されたすべてのvbコードは不要で、プロジェクトを膨らませるだけです。

代わりに、サービス参照としてwsdlを追加したので、アプリケーションのメソッドから直接Webサービスを呼び出すことができます。サービス参照が追加されると、サービスが追加したクラスであるかのように、すべてのWebメソッドにプロジェクトからアクセスできます。あなたがリンクしているwsdlから、SendMessageメソッドが使いたいメソッドであるように見えます。

Public Sub SendMyMessage() 
    Dim password As New Byte 
    Dim userId As String = "MyUserId" 
    Dim nonce As String = "I'm not sure what this is" 
    Dim ts As Date = Date.Now 'I initialized this with the current date 
    Dim message As New Byte 'This is your message 
    Dim webservice As New FwHL7 'This would be the name of your web service reference 
    Dim response = webservice.SendMessage(userId, password, nonce, ts, message) 'This is where you actually invoke the webservice and load its response into a variable 
End Sub 

そこから、メッセージを記録するコードを追加するだけです。

関連する問題