0 Replies Latest reply on Feb 25, 2011 9:36 PM by Worrow W

    SoapAction not required?

    Worrow W Newbie

      Hi,

       

      I got some Web Service running in Jboss 4.2.3GA.  Tried to build a console client that called the Service with SoapMessage.

      Here is the code below:

      // --------------------------------------------------------------------------------------------------------------------------------------------------------------

      SOAPMessage requestMsg = SoapUtils.emptyMessage();

        SOAPPart soapPart = requestMsg.getSOAPPart();
        SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
        SOAPBody soapBody = soapEnvelope.getBody();
        SOAPHeader soapHeader = soapEnvelope.getHeader();
        soapEnvelope.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");
         requestMsg.getMimeHeaders().addHeader("SOAPAction", "urn:enquireDataset");
        Name bodyName = soapEnvelope.createName("enquireDataset", "fd",
          "http://impl.ws.eadi.com");
        SOAPBodyElement bodyElement = soapBody.addBodyElement(bodyName);
        // userID
        Name userID_soap = soapEnvelope.createName("userID", "fd",
          "http://impl.ws.eadi.com");
        SOAPElement soapElement = bodyElement.addChildElement(userID_soap);
        soapElement.addTextNode(userID);
        // password
        Name password_soap = soapEnvelope.createName("password", "fd",
          "http://impl.ws.eadi.com");
        soapElement = bodyElement.addChildElement(password_soap);
        soapElement.addTextNode(password);
        // logicalDatasetName
        Name logicalDatasetName_soap = soapEnvelope.createName(
          "logicalDatasetName", "fd", "http://impl.ws.eadi.com");
        soapElement = bodyElement.addChildElement(logicalDatasetName_soap);
        soapElement.addTextNode(logicalDatasetname);
      // --------------------------------------------------------------------------------------------------------------------------------------------------------------

      When I called the service, Jboss server threw:

      10:27:56,125 ERROR [[AxisServlet]] Servlet.service() for servlet AxisServlet thr

      ew exception

      java.lang.StringIndexOutOfBoundsException: String index out of range: -1

              at java.lang.String.substring(String.java:1938)

      But after I  replaced the SoapAction line with 'requestMsg.getMimeHeaders().addHeader("Content-Type", "text/xml");', it works fine.  What is the reason behind this?  Is the value of "SOAPAction" caused the problem[I copied it from wsdl, action tag]?  Or in some case, SoapAction is not required at all?

       

      Any help will be really appreciated!  Thanks in advance.