Web Services: SoapException was Unhandled by User

Posted on 2011-09-08
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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?
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now


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 125 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 125 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 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