Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Web Services: SoapException was Unhandled by User

Posted on 2011-09-08
10
Medium Priority
?
2,826 Views
Last Modified: 2012-05-12
Hi,

I created a web service
This has one method with a parameter and returns a value.

String fare= GetFare(ClientID)

When i run the service, it works good. No issues.
I deployed it to my local server(LocalA). The database is at a remote server(RemoteA).

When i try to consume it from a client, after deploying on a server, i am getting Soap Exception was unhandled by user code.
Server was unable to process request.

Attaching my code below:


Thanks




<WebMethod()> _
    Public Function GetFare(ByVal clntid As String) As String
        Dim tripfr As String = Nothing
        Dim constring As String = Nothing
        constring = System.Configuration.ConfigurationManager.ConnectionStrings("WS").ConnectionString.ToString

        Dim mycon As New SqlConnection(constring)


        Dim strquery As String = Nothing
        strquery = "select fare from schedules  where clntid = '" & clntid & "'"
        Try
            mycon.Open()
            Dim mycmd As New SqlCommand(strquery, mycon)
            Dim myreader As SqlDataReader = Nothing
            myreader = mycmd.ExecuteReader()

            While myreader.Read
                tripnm = myreader.Item(0)
            End While
        Catch soapex As SoapException
         
        Finally

        End Try


        Return tripfr 

    End Function



Client Application to Consume:


Private Sub Sh_Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sh_Button1.Click


        Dim callService As New MDC.myMDCService

        Dim tripfr As String = Nothing
        tripfr = callService.GetRecord(textbox1.Text) /////// -- Error Here.


        MessageBox.Show(tripfr)

    End Sub

Open in new window

0
Comment
Question by:shahjagat
  • 5
  • 3
  • 2
10 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36506745
CatchCatch soapex As SoapException

Open in new window

That line of code isn't going to do you any good because your service code isn't the layer that's raising the SOAP excpetion--it's an underlying layer in the runtime. Most likely, you've got an exception dealing with SQL Server, so I'd suggest changing SoapException to SqlException. Also, you would want to catch a SoapException in your client code, not the server code.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36506753
In code, the last sentence in my previous comment would be:
Try
    tripfr = callService.GetRecord(textbox1.Text)
Catch soapex As SoapException
    Console.WriteLine(soapex.ToString())  ' For example
End Try

Open in new window

0
 
LVL 9

Expert Comment

by:Grant Spiteri
ID: 36506818
Ok few questions:

1. The server where the Application resides (Client), is this on a different domain / server to the actual service?
2. What type of authentication is set on both the service and application?
3. Have you created specific users for the app pools that both the application & service reside?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:shahjagat
ID: 36506886
Hi Kaufmed,

This is my error message: Do you tthink some thing wrong with connection to sql server?

Server was unable to process request. ---> A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.)
0
 

Author Comment

by:shahjagat
ID: 36506898
gspiteri,

Server where Web service is hosted is in our office in our network.
Database Server is locatesd at a remote location on a different network  They are on different domains.

Not sure about ur questions 2 and 3.
I did not create anything else at all.

thanks
0
 
LVL 9

Accepted Solution

by:
Grant Spiteri earned 500 total points
ID: 36507300
is your service set up in IIS with windows authentication only etc...

Im running windows 7 so im just going off my iis manager:

Question 2: if you go to IIS Manager select your service and under the security section double click on authentiction to aquire what i need to know

Question 3: stay in the iis manager right click on the service and select manage application and the select advance, take note of the value next to the application pool option. Then close out of that and select application pools under the top level of the tree in the manager on the left, right click on the app pool from the service click advance settings, then under process model next to option identity is it a custom username or simply ApplicationPoolIdentity

also i would just double check permissions on the db for the user assigned to the connection string in your config
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 500 total points
ID: 36507387
Make sure your connection string to your database is configured properly as well  = )
0
 

Author Comment

by:shahjagat
ID: 36512210
Hi gspiteri and kaufmed,

I think the issue was with the sql server on our server. It was not seeing/communicating with the external server.
When this part worked, web service worked.

Giving points to both.

Thanks
0
 

Author Closing Comment

by:shahjagat
ID: 36512216
Thanks
0
 

Author Comment

by:shahjagat
ID: 36512221
Edit: Issue was with the local server where the web service was deployed. (not sql server as mentioned)
When we restarted  the server it worked.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question