Webservice not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SwapnilD
    New Member
    • Jan 2010
    • 41

    Webservice not working

    I have created a web service on my local machine (C:\Inetpub\www root\Converter) using vb.net version 1.1.

    Purpose of webservice: this webservice will be invoked by a third party website (say abc.com). User will add a message in a webpage of abc.com this message will be sent to the Webservice.

    Below mentioned is the code that I have written for a web service to store the parameters/message sent by third party application.

    -- Service1.asmx page
    Code:
    Imports System.Web.Services
    Imports System.Web
    Imports System.Data.SqlClient
    Imports System.Collections.Specialized
    Imports System.Web.Services.Protocols
    
    <System.Web.Services.WebService(Namespace:="http://www.MyWebsiteAddress.com/Converter/Service1")> _
    Public Class Service1
        Inherits System.Web.Services.WebService
    
        ' WEB SERVICE EXAMPLE
        ' The HelloWorld() example service returns the string Hello World.
        ' To build, uncomment the following lines then save and build the project.
        ' To test this web service, ensure that the .asmx file is the start page
        ' and press F5.
    
    
        <WebMethod()> _
        Public Sub ProcessRequest(ByVal userKey As String, ByVal message As String, ByVal listen As String) // Mentioned here are the parameters will be sent to this web service
          Dim strcon As String
            strcon = "server=ip; database=dbname; uid=XXX; pwd=XXX"
            Dim objConn As New SqlConnection(strcon)
            Dim objTrans As SqlTransaction
            objConn.Open()
            objTrans = objConn.BeginTransaction
            Dim strSQL As String = ""
            strSQL = "insert into TableName (UserKey,Message,Voicelink)values"
            strSQL = strSQL + "('" & userKey & "','" & message & "','" & listen & "')"
            Dim cmd As New SqlCommand(strSQL, objConn)
            cmd.Transaction = objTrans
            cmd.CommandType = Data.CommandType.Text
            cmd.ExecuteNonQuery()
            objTrans.Commit()
    
        End Sub
    
    End Class
    After testing the web service on a local envoirement I found that it is working properly. I uploaded service1.asmx, service1.asmx.v b files to the root directory of source code of online development web server and uploaded Converter.dll and Converter.pdb file to the bin folder of web server.
    After doing this process i tested the webservice by http://MyWebsiteName.com/Service1.asmx and recived error "The test form is only available for requests from the local machine.".. To resolve this error I added below mentioned code in the web.cong file of application not in the web.config of Webservice.
    Code:
    <webServices>
    	 <protocols>
    	 	<add name="HttpGet"/>
    		<add name="HttpPost"/>
    	</protocols>
     </webServices>
    after adding the above code webservice was working properly through the browser.

    Now the third party application has asked to enter the link of webservice which will receive the hit when user add the message, so I have given it as http://MyWebsiteName.com/Service1.asmx.

    But when I try to send the message from third party application as a part of testing in a real envoirenment I should get a hit to the above mentioned URL (Web Service), But, I'm not getting a hit(Data is not saved into the database).

    So, I think, either my web service is not deployed properly (the porcess I have done of coping the files and .DLL to the development server is not sufficent to get the hit from third party) or the code written in SUB ProcessRequest is not able to recieve the query string parameters from the thrid party application.

    Please note that I'm creating the web service in Microsoft Visual Studio .NET 2003 using VB.net

    Please help its urgent.

    Thanks,

    Swapnil
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by SwapnilD
    SwapnilD:
    But when I try to send the message from third party application as a part of testing in a real envoirenment I should get a hit to the above mentioned URL (Web Service), But, I'm not getting a hit(Data is not saved into the database).
    Since you are able to consume to web service in your own code (I'm assuming you tested this properly), I would say that the 3rd party application isn't consuming your web service properly.

    -Frinny

    Comment

    Working...