Forum Discussion

boekhold's avatar
boekhold
New Contributor
13 years ago

Missing operation for soapAction when using SAAJ attachment

Hi all,

I'm trying to develop a Web Service client that uses SAAJ and an application/pdf attachment to the WS operation call. The code basically looks like:


SOAPMessage msg = messageFactory.createMessage();
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
SOAPBody bdy = env.getBody();

env.addNamespaceDeclaration(NSPREFIX, NAMESPACE);

SOAPBodyElement op = bdy
.addBodyElement(name("AddDocumentWithContent"));
SOAPElement bussCode = op.addChildElement("arg0");
SOAPElement propVal = op.addChildElement("arg1");
SOAPElement mimeType = op.addChildElement("arg2");

bussCode.addTextNode(businessCode);
propVal.addTextNode(propValues);
mimeType.addTextNode(content.getMimeType());

// Attach our document
InputStream is = content.getData();
if (is != null) {
LOG.debug("attaching document of type {}", content.getMimeType());
AttachmentPart part = msg.createAttachmentPart();

// ByteArrayDataSource from javax.mail API
part.setDataHandler(
new DataHandler(
new ByteArrayDataSource(is, content.getMimeType())));
msg.addAttachmentPart(part);
}

msg.saveChanges();

SOAPMessage res = call(msg);


I'm testing against a Mock Service in SoapUI 4.5.1.

The above call works in case is==null. However as soon as I open an InputStream as:


new FileInputStream("C:/software/lib/apache-ant-1.7.0/docs/appendix_e.pdf");


then SoapUI fails with:


SoapUI Log:
Mon Mar 25 10:47:25 GST 2013:ERROR:An error occured [Missing operation for soapAction [] and body element [null] with SOAP Version [SOAP 1.1]], see error log for details

error log:
Mon Mar 25 10:47:26 GST 2013:ERROR:com.eviware.soapui.impl.wsdl.mock.DispatchException: Missing operation for soapAction [] and body element [null] with SOAP Version [SOAP 1.1]
com.eviware.soapui.impl.wsdl.mock.DispatchException: Missing operation for soapAction [] and body element [null] with SOAP Version [SOAP 1.1]
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchPostRequest(WsdlMockRunner.java:318)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:375)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:715)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
...


I've done a lot of googling on this, and none of the suggestions I found helped:

- Disable Mock HTTP Log
- ensure Require SOAP Action == false

Any suggestions? Is this supposed to be supported by SoapUI?

Maarten

3 Replies

  • boekhold's avatar
    boekhold
    New Contributor
    Hi all,

    I'm getting the impression that the HTTP headers aren't being set correctly. I think SoapUI expects "Content-Type: multipart/related" as an HTTP header, and that my client program uses "text/xml" instead.

    I have no idea how to control this? Isn't the API supposed to manage that for you once you do msg.addAttachmentPart()?

    I'm running my client program inside Eclipse (3.6.1) on Windows Server 2008 64bit with Java SE 7.

    Maarten
  • boekhold's avatar
    boekhold
    New Contributor
    Hmmm, installed wireshark to look at the actual data sent to SoapUI (can't find a working download link for Apache TCPMon anywhere!!!!).

    The client is definitely using

    Content-Type: multipart/related; type="text/xml"; boundary="----=_Part_0_1576039226.1364199376012"

    At this point I just don't know if there's a problem with my WS client or with SoapUI...

    Maarten
  • boekhold's avatar
    boekhold
    New Contributor
    Hi,

    Been comparing the full message that SoapUI generates if I call an operation against what my SAAJ java client generates. I noticed that my call doesn't have a "SOAPAction: """ in the HTTP headers. So I added that. No difference.

    I then noticed that SoapUI adds a "start" element to the Content-Type header as:


    Content-Type: multipart/related; type="text/xml"; start="<rootpart@soapui.org"; boundary="----=_Part_0_1576039226.1364199376012"


    and that it has the Content-ID header of the SOAP Part set to that start value as well.

    I tried to tweak the Content-Type header that my SAAJ client program generates, but that fails:


    msg.getMimeHeaders().addHeader("Content-Type", "start=\"rootpart\"");


    This generates a SAAJ exception when calling msg.saveChanges(). I do somehow think that this missing "start" element is the reason why calling a SOAP UI Mock Service from my SAAJ client program is failing. In which case: is that a bug in SoapUI?

    Maarten