Skip to main content

Posts

Showing posts from November, 2011

How to create a java SOAP Client to test a .Net web service

This is how you can test your web service in Java without creating any SOAP Client. Using this you can access Web Services created using any technology, in specific .Net.


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.fugoconsulting;

import java.io.InputStreamReader;
import java.net.URL;

/**
 *
 * @author pandi
 */
public class sendRequest {

    public String sendRequestToIRDA(String request) {

    String response = "";
    try {
            String soapXml = request;
            URL url = new URL("http://127.0.0.1/Service/TestService.asmx"); //for testing .Net Service
            java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url.openConnection();
            conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
   conn.setRequestProperty("SOAPAction", "http://test/Service/Test");
   conn.setRequestProperty("Content-Length"…