Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Web Services: SoapException was Unhandled by User

Posted on 2011-09-08
Medium Priority
Last Modified: 2012-05-12

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:


<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 & "'"
            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

        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.


    End Sub

Open in new window

Question by:shahjagat
  • 5
  • 3
  • 2
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.
LVL 75

Expert Comment

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

Open in new window


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?
Industry Leaders: 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

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.)

Author Comment

ID: 36506898

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.


Accepted Solution

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
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  = )

Author Comment

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.


Author Closing Comment

ID: 36512216

Author Comment

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.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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.
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

564 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