0

Ok here is my story, i have java web service from third party i have to connect to this service using C# this service require the following

  • Authentication using Username & Password.
  • Certificate send from the client "keystore.jks" (Java Keystore file) with password.

My problem is the vendor of this service is not providing the WSDL link for the service and the certificate file is java keystore I'm hanging on this for 2 days and search for this on the web with no luck

Hence : I used SOAPUI software to call this service and its working well

What i want is, Is it possible to consume this service without requesting WSDL from the vendor? if yes how ?

Any help well be appreciated. Thanks in advance.

EDIT: service url like https://10.111.10.12/ropnrs/Person?crn=1234567 And it's not accessible throw web browser return 403 forbidden

2
  • I'm not sure why you have put the REST word between quotes. Is this because it is actually a SOAP service with a json object in the body of the message ? REST don't have WSDL as a standard way to expose metadata. However, I posted a solution which provides you the necessary control on sending "raw" requests like you do with SOAP UI. Commented Jan 15, 2015 at 6:41
  • i put REST because when calling it throw SOAPUI it require REST project it's my first time to call non .Net Services. Commented Jan 15, 2015 at 7:20

1 Answer 1

1

You can consume a webservice without a WSDL by sending a POST request with the WebClient, and filling the body of the request with the SOAP XML message.

You might need to add additional HTTP headers. First do a request with SOAP UI and look at the request with fiddler. Then send the request with WebClient. The code should be similar to this:

using (var client = new WebClient())
{
    // this is the string containing the soap message
    var data = File.ReadAllText("request.xml");
    // HTTP header. set it to the identical working example you monitor with fiddler from SOAP UI
    client.Headers.Add("Content-Type", "text/xml;charset=utf-8");
    // HTTP header. set it to the identical working example you monitor with fiddler from SOAP UI 
    client.Headers.Add("SOAPAction", "\"http://tempuri.org/ITestWcfService/TestMethod\"");
    // add/modify additional HTTP headers to make the request identical with what you get when calling from SOAP UI on a successful call 
    try
    {
        var response = client.UploadString("http://localhost:8080/TestWcfService", data);
    }
    catch (Exception e)
    {
        // handle exception                        
    }
}

I'm not sure about the certificate, but maybe you can set it to the web client too somehow. Unfortunately, I don't know much about client certificates. But if you can explain in comments I might be able to help you. If you manage to make it work using this solution, please also post here your additional work to handle the certificate problem.

WebClient is the class from System.Net in System.dll assembly.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for the answer, but the service is not WCF, it's java web service and its REST service. i tried to capture the request with fiddle and nothing captured.
It doesn't matter, as long as you send the right message. WebClient is for sending raw requests. If you can update the question to include the raw request you send with SOAP UI I could advice another more specialized class from .NET.
i can't capture the request from fiddler when calling service throw SoapUI i don't know if below request details from SoapUI hepls ` GET 10.111.10.12/ropnrs/Person?crn=1234567 HTTP/1.1 Accept-Encoding: gzip,deflate Authorization: Basic TU9NUDpNT01QQCQkdzByZA== Accept-Language: ar-OM Accept: text/xml Host: 10.111.10.12 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5)`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.