我在IIS上託管一個WCF服務(一個服務函數庫)。vb.net WCF服務庫函數沒有公開 - 它只能看到IIS主機的默認服務(2個函數)
我應該看到(公開)我的服務庫中創建的NotificationsService的函數 - NotificationAdd - 但我不知道。有人知道爲什麼
我使用VS 2013創建了3個項目VB.net解決方案。 1個項目爲WCF服務庫 1個項目爲IIS主機。 1個UI項目。
WCF服務庫的項目。 1個功能服務。被稱爲NotificationsServiceLibrary。
的INotificationsService.vb
Imports System
Imports System.ServiceModel
Imports System.ServiceModel.Web
Namespace NotificationsServiceLibrary
<ServiceContract()>
Public Interface INotificationsService
<OperationContract>
Function NotificationAdd(ByVal pStrUserName As String, ByVal pStrPassword As String, ByVal pStrEmailAddress As String, ByVal pStrSummary As String, ByVal pStrDetail As String, ByVal pStrSource As String, ByVal pStrSourceURL As String, ByVal pDtWhenGenerated As Date, ByVal pDdtSchedule As Date) As NotificationsInfoResult
End Interface
End Namespace
的NotificationsService.vb
Imports System
Imports System.IO
Imports System.ServiceModel
Imports System.Configuration
Imports System.Xml
Imports System.Data.SqlClient
Namespace NotificationsServiceLibrary
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.Single)>
Public Class NotificationsService
Implements INotificationsService
Public Function NotificationAdd(ByVal pStrUserName As String, ByVal pStrPassword As String, ByVal pStrEmailAddress As String, ByVal pStrSummary As String, ByVal pStrDetail As String, ByVal pStrSource As String, ByVal pStrSourceURL As String, ByVal pDtWhenGenerated As Date, ByVal pDdtSchedule As Date) As NotificationsInfoResult Implements INotificationsService.NotificationAdd
' Code here..but removed to keep this short.
' Return.
Return notificationsInfoResult
End Function
End Class
End Namespace
的NotificationsServiceData.vb
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Runtime.Serialization
<DataContract()>
Public Class NotificationsInfoResult
Private _result_code As Integer
<DataMember()>
Public Property Result_Code() As Integer
Get
Return _result_code
End Get
Set(value As Integer)
_result_code = value
End Set
End Property
End Class
以下是IIS主機項目,我發佈到IIS。稱爲:NotificationsApiIISHost。 在IIS主機項目中,我添加了對NotificationsServiceLibrary的項目引用。 如果我點擊它,我可以在對象瀏覽器中看到我應該暴露的1個函數。
的IIS主機項目2個標準的默認文件(我不使用也不修改),並且我加入到Web.config:
IService1.vb
<ServiceContract()>
Public Interface IService1
<OperationContract()>
Function GetData(ByVal value As Integer) As String
<OperationContract()>
Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType
' TODO: Add your service operations here
End Interface
' Use a data contract as illustrated in the sample below to add composite
types to service operations.
<DataContract()>
Public Class CompositeType
<DataMember()>
Public Property BoolValue() As Boolean
<DataMember()>
Public Property StringValue() As String
End Class
Service1.svc
Public Class Service1
Implements IService1
Public Sub New()
End Sub
Public Function GetData(ByVal value As Integer) As String Implements IService1.GetData
Return String.Format("You entered: {0}", value)
End Function
Public Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType Implements IService1.GetDataUsingDataContract
If composite Is Nothing Then
Throw New ArgumentNullException("composite")
End If
If composite.BoolValue Then
composite.StringValue &= "Suffix"
End If
Return composite
End Function
End Class
的IIS主機的web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<services>
<service name="NotificationsServiceLibrary.NotificationsServiceLibrary.NotificationsService">
<!-- Service Endpoints -->
<endpoint address="Notifications" binding="wsHttpBinding" contract="NotificationsServiceLibrary.NotificationsServiceLibrary.INotificationsService" bindingConfiguration="NoSecurityConfig" >
</endpoint>
<!-- Metadata Endpoints -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="NoSecurityConfig">
<security mode="None">
<transport clientCredentialType="None" />
<message establishSecurityContext="false" />
</security>
<reliableSession enabled="true" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
構建併發布主機之後。
以下是在IIS上自動創建的Service1.svc文件的內容。
<%@ ServiceHost Language="VB" Debug="true"
Service="NotificationsApiIISHost.Service1" CodeBehind="Service1.svc.vb" %>
我得到VS: ------發佈開始:項目:NotificationsApiIISHost,配置:調試任何CPU ------ 連接到ftp://dev.notifications.xxxx.net:2121 ... 轉化利用的Web.config C:\ Dans \ Work 2 \ xxxx \ NotificationsApiIISHost \ Web.Debug.config轉換爲obj \ Debug \ TransformWebConfig \ transformed \ Web.config。 將所有文件複製到以下臨時位置以進行打包/發佈: obj \ Debug \ Package \ PackageTmp。 刪除現有文件... 發佈文件夾/ ... 發佈文件夾bin ... 網站已成功發佈ftp://dev.notifications.xxxx.net:2121/ 網站已成功發佈http://dev.notifications.xxx.net/ ==========構建:0成功,0失敗,2最新,0跳過========== ==========發佈:1次成功,0次失敗,0次跳過==========
我在顯示的頁面上單擊Service1.svc:
dev.notifications.xxxxxx.net -/
2015年10月1日下午10時49分倉
10 /二千○十五分之一下午10時49分120 Service1.svc
2015年10月1日下午10時49分2900的Web.config
然後我點擊http://xxxxx/Service1.svc?singleWsdl和 所有我看到的是默認的主機服務功能 - GetData和GetDataUsingDataContract。 當我創建IIS主機時,這些放置在那裏。甚至沒有用過我。 我應該看到我在我的服務庫中創建的功能,但我不知道。
這裏的WSDL的部分:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" name="Service1" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<xs:import namespace="http://schemas.datacontract.org/2004/07/NotificationsApiIISHost"/>
<xs:element name="GetData">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="value" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetDataResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="GetDataResult" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetDataUsingDataContract">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/NotificationsApiIISHost" minOccurs="0" name="composite" nillable="true" type="q1:CompositeType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetDataUsingDataContractResponse">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q2="http://schemas.datacontract.org/2004/07/NotificationsApiIISHost" minOccurs="0" name="GetDataUsingDataContractResult" nillable="true" type="q2:CompositeType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified"
我沒有明白你想要什麼......你想公開NotificationsService方法NotificationAdd? –
@Ricardo。對,就是這樣。 – user3020047