alan
alan

Reputation: 6933

.NET Client consuming AXIS 1.4 SSL Webservice all exceptions "INTERNAL SERVER ERROR"

I need to consume an AXIS 1.4 Web service over SSL from a .NET client. Currently we implement the System.Net.WebClient, we hand create the XML request and upload it to the web service. This works great for getting back valid results, however if an exception occurs (java.rmi.RemoteException) we only get back a WebException of "Interal Server Error". Inspecting the response yields no more detail.

If we add the service in Visual Studio 2010 as a .NET 2.0 Web Reference (SoapHttpClientProtocol) we receive the desired java.rmi.RemoteException with all the necessary details to rectify the problem. However, all resulting responses from a valid request are null.

Note: This service is being consumed successfully by other (competitors') .NET Clients (to which we do not have the source code).

To reiterate: A valid request via WebClient receives valid response objects but every exception is an "Internal Server Error", a valid request via Web Reference receives null responses but will accurately display the desired java.rmi.RemoteException.

The goal: Valid responses along with complete java.rmi.RemoteExceptions (not vague Internal Server Errors), even if I can get a SoapException to be thrown that'd be a huge improvment.

IDE: Visual Studio 2010 SP1

OS: Windows 7

.NET: 2.0/3.5/4.0 (I have attempted all three versions with the same results)

Language: C#

Example WebClient code:

var lvResult = "";

        try
        {
            var lvStr = "sample request";
            var client = new WebClient();
            client.Headers.Add("SOAPAction", "SampleRequest");

            lvResult = client.UploadString(cvURL, lvStr);
        }
        catch (Exception ex)
        {

        }

UPDATE: To be more specific, this wouldn't be a problem if a Soap exception was being thrown, however the only exception thrown is a "WebException" which doesn't seem to give me access to the faultstring. Below is the raw soap fault I'm receiving from the AXIS service:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
<soapenv:Fault>
  <faultcode>soapenv:Server.userException</faultcode>
  <faultstring>java.rmi.RemoteException: Error in posting Request: Code 02 - No UserId for this user name/password.</faultstring>
  <detail>
    <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">xxxx</ns1:hostname>
  </detail>
</soapenv:Fault>

SOLUTION: I found a workaround by catching the WebException, and grabbing the response stream for the exception response -

    catch(WebException pvEx)
    {
        var lvResponseString = "";

        if (pvEx.Response != null)
        {
            using (var lvStreamReader = new StreamReader(pvEx.Response.GetResponseStream()))
            {
                //This string now contains the xml soap response
                lvResponseString = lvStreamReader.ReadToEnd(); 
            }
        }

    }

Upvotes: 2

Views: 1583

Answers (1)

kroonwijk
kroonwijk

Reputation: 8400

This is a post on exactly the problem you have: http://bytes.com/topic/net/answers/427757-soap-faults.

I think your AXIS service IS returning a SOAPFAULT. You just need to know how to deal with it in your .NET client. And that is described in this post.

Best regards, Marco Kroonwijk

Upvotes: 1

Related Questions