0

Is there a way to send a SOAP message to a URL without using the another URL which actually hosts the WSDL file. My current Java implementation looks like this

  void send(String alias,String message){
    
    try{ 
      systemMessage("Entering Try");
  
     String url="https://connect.mycass.in/pool-01/AVL/message/inbound/soap";  
      
        

    
    URL obj=new URL(url);
      

      
       systemMessage("Proxy Set");
      
      
    HttpURLConnection con=(HttpURLConnection) obj.openConnection();
    con.setRequestProperty("SOAPAction","http://www.bsnlmsg.in/SendMessage");
      

    con.setRequestMethod("POST");  /* Post Request to URL*/
    con.setRequestProperty("Content-Type","text/xml; charset=utf-8");

    
       systemMessage("Post Message");
    
      
      


String xml= "<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <SendMessage xmlns=\"http://www.bsnlmsg.in/\"> <sAlias>"+alias+"</sAlias> <sPassword>helo123</sPassword> <sMessage>"+message+"</sMessage> </SendMessage> </soap:Body> </soap:Envelope>";     
    con.setDoOutput(true);
    DataOutputStream wr = new DataOutputStream(con.getOutputStream());
    wr.writeBytes(xml);
    wr.flush();
    wr.close();
 
      
      
        String responseStatus=con.getResponseMessage();

 
    
    BufferedReader in=new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    
    StringBuffer response=new StringBuffer();
    while((inputLine=in.readLine())!=null)
    {
      
      response.append(inputLine); 
    }
    in.close();
 
      
       systemMessage("Try Exiting");
     systemMessage("Response::"+response.toString());
    }
    
    catch(Exception e){
       systemMessage("Step Exception");
      systemMessage(e.getMessage()); 
      
    }
  }

The URL http://www.bsnlmsg.in/SendMessage will be discontinued by the service provider. So the WSDL will not be available for use anymore. So now I have to send a message (String characters) to the URL https://connect.mycass.in/pool-01/AVL/message/inbound/soap without using the WSDL provided by bsnlmsg ,how do I overcome this situation? OR should I host a new webservice somewhere in my IT network?

NIKHIL
  • 7
  • 2
  • I don't think that you need a WSDL. You just send the XML to the service URL. – Stefan Jan 11 '21 at 16:27
  • The WSDL and the web service are two different things. As resources you can decouple them completely. What ties them together is the notion of a contract, a contract that the web service implements and the WSDL describes. See here for more details: https://stackoverflow.com/questions/65598875/how-is-a-soap-call-possible-without-wsdl/65647313#65647313 – Bogdan Jan 11 '21 at 18:53

0 Answers0