[jboss-user] [JBoss Web Services] - SoapAction not required?

Worrow W do-not-reply at jboss.com
Fri Feb 25 21:33:43 EST 2011


Worrow W [http://community.jboss.org/people/worrow] created the discussion

"SoapAction not required?"

To view the discussion, visit: http://community.jboss.org/message/589821#589821

--------------------------------------------------------------
Hi,

I got some Web Service running in Jboss 4.2.3GA.  Tried to build a console client that use 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/ http://schemas.xmlsoap.org/soap/encoding/");
   requestMsg.getMimeHeaders().addHeader("SOAPAction", "urn:enquireDataset");
  Name bodyName = soapEnvelope.createName("enquireDataset", "fd",
    " http://impl.ws.eadi.com http://impl.ws.eadi.com");
  SOAPBodyElement bodyElement = soapBody.addBodyElement(bodyName);
  // userID
  Name userID_soap = soapEnvelope.createName("userID", "fd",
    " http://impl.ws.eadi.com 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 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 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.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/589821#589821]

Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110225/045b917d/attachment.html 


More information about the jboss-user mailing list