Problem with Webservice Error Web Service Method is not valid

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<pre> Hi!<br/>I ve got a Problem with a Webservice. I ve Scripted it in VB.net -- Please has anybody an Idea why this happens -- I cant find the Problem <pre class="prettyprint lang-vb Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Web.Configuration
Imports System.Web.Management
Imports System.Data.SqlClient.SqlDataReader
Imports System.Data.SqlClient
Imports System.Management
<System.Web.Services.WebService(Namespace:="SPECIALMDT.Service1")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService
#Region "Instance variables"
Private _rootServer As String = ""
Private _slpServer As String = ""
Private _ConnectionString As String = ""
#End Region
#Region "Initialization"
Public Sub New()
Read the root server parameter
Me._rootServer = WebConfigurationManager.AppSettings.Item("RootServer")
Trace.WriteLine(("MyMDTWebService: Specified root server is " & Me._rootServer))
Me._slpServer = WebConfigurationManager.AppSettings.Item("SLPServer")
Trace.WriteLine(("MyMDTWebService: Specified SLP server is " & Me._slpServer))
Get Connection String from web.config
Me._ConnectionString = ConfigurationManager.ConnectionStrings("MDTDB").ConnectionString
Trace.WriteLine(("MyMDTWebService: Connection String is " & Me._ConnectionString))
End Sub
#End Region
Public Function RetrieveSCCMPKG() As List(Of Names)
Using connection = New SqlConnection(_ConnectionString)
connection.Open()
Dim command = New SqlCommand("RetrieveSCCMPKG", connection)
command.CommandType = CommandType.StoredProcedure
Using dr = command.ExecuteReader()
Dim result = New List(Of Names)()
While dr.Read()
result.Add(New Names() With { _
.PkgId = DirectCast(dr("PkgId"), String), _
.Name = DirectCast(dr("Name"), String) _
})
End While
Return result
End Using
End Using
End Function
End Class
Public Class Names
Public Property PkgId() As String
Get
Return m_PkgId
End Get
Set(ByVal value As String)
m_PkgId = value
End Set
End Property
Private m_PkgId As String
Public Property Name() As String
Get
Return m_Name
End Get
Set(ByVal value As String)
m_Name = value
End Set
End Property
Private m_Name As String
#Region "Utilities"
#End Region
End Class[/code] My web.Config looks like this: <pre class="prettyprint <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
<section name="Koster.MDT.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="RootServer" value="MySCCMServer" />
<add key="SLPServer" value="MySCCMServer" />
<add key="RootSiteCode" value="AT1" />
<add key="ADDomain" value="MyDomain" />
<add key="ADUsername" value="" />
<add key="ADPassword" value="" />
<add key="MDTDBServer" value="MySCCMServer" />
<add key="MDTDBName" value="mdt_at1" />
<add key="MDTDBIntegratedSecurity" value="True" />
<add key="MDTDBUser" value="YourMDTDBAdminAccount" />
<add key="MDTDBPassword" value="YourMDTDBAdminAccountPw" />
<add key="IncludeFunctions" value="*" />
<add key="ExcludeFunctions" value="" />
<add key="IncludeADFunctions" value="" />
<add key="ExcludeADFunctions" value="DeleteComputer,DeleteComputerForced,SetComputerAttribute,DeleteUser,DeleteUserForced,SetUserAttribute" />
<add key="IncludeSCCMFunctions" value="" />
<add key="ExcludeSCCMFunctions" value="DeleteComputer,DeleteComputerByID" />
<add key="IncludeMDTFunctions" value="" />
<add key="ExcludeMDTFunctions" value="" />
<add key="IncludeSMSCliCtrFunctions" value="" />
<add key="ExcludeSMSCliCtrFunctions" value="" />
<add key="IncludeSpecialMDT" value="RetrieveSCCMPKG" />
</appSettings>
<connectionStrings>
<add name="MDTDB" connectionString="Data Source=MySCCMServer;Initial Catalog=mdt_at1;Integrated Security=SSPI;"/>
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<compilation strict="false" explicit="true" />
<pages>
<namespaces>
<clear />
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
<add namespace="System.Data.SqlClient.SqlDataReader" />
<add namespace="System.Data.SqlClient" />
<add namespace="System.Management" />
<add namespace="System.Data.SqlClient" />
<add namespace="System.Web.Services" />
<add namespace="System.ComponentModel" />
<add namespace="System.Web.Configuration" />
<add namespace="System.Web.Management" />
<add namespace="System.Web.Services.Protocols" />
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace. -->
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
<webServices>
<protocols>
<add name="HttpPost" />
<add name="HttpGet" />
<add name="Documentation" />
</protocols>
<wsdlHelpGenerator href="MKWsdlHelpGenerator.aspx" />
</webServices>
</system.web>
<system.diagnostics>
<trace autoflush="true" indentsize="4
<listeners>
<add name="TraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:TempMyMDTTrace.log"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>[/code] <br/> Now when I Call this Webservice with my *.asmx File I get the following Error <pre class="prettyprint System.InvalidOperationException: RetrieveSCCMPKG Web Service method name is not valid.
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)[/code] I have Changed the Webservice and also the Webconfig but I dont know what setting is false<br/>Can anybody who had this Problem help me<br/>Thx for your Answers in Advance MichaelF2050 [/code]
<br/>

View the full article
 
Back
Top