tags:

views:

51

answers:

1

I am having a rather frustrating issue trying to call a web service that requires an attachment.

This is the error:

Unexpected Attachment type =class java.lang.Object

from here:

class="com.sun.xml.ws.client.sei.ResponseBuilder$AttachmentBuilder" file="ResponseBuilder.java" line="250" method="createAttachmentBuilder"

The method the web proxy gives me is this:

  public Reply putDocument(
    @WebParam(targetNamespace="uri:put.document", partName="request", name="request")
      StoreType request,
    @WebParam(targetNamespace="", partName="put", name="put")
      Object put);

What I cannot figure out is what to pass in for "put", which is only defined as an Object.

I have tried:

byte[]
String
DataHandler(ByteArrayDataSource)
uri.put_document.ObjectFactory.createPut(byte[])
AttachmentPart

I have also tried looking for the code but haven't had luck so far.

EDIT: WSDL is as follows.

<?xml version="1.0" encoding="UTF-8" ?>
<definitions targetNamespace="urn:fer"
             xmlns="http://schemas.xmlsoap.org/wsdl/"
             xmlns:tns="urn:fer"
             xmlns:get="uri:get.document"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
             xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"&gt;
  <types>
      <xsd:schema>
        <xsd:import namespace="uri:get.document"
                    schemaLocation="../xsd/getDocument.xsd"/>
      </xsd:schema>
  </types>
  <message name="putDocument">
    <part name="request" element="put:request"/>    
    <part name="put" element="put:put"/>
  </message>
  <message name="putDocumentReply">
    <part name="reply" element="put:reply"/>    
  </message>
  <portType name="FrontEndRepository">
    <operation name="putDocument">
      <input message="tns:putDocument"/>
      <output message="tns:putDocumentReply"/>
    </operation>
  </portType>
  <binding name="frontEndRepositoryPortSOAP11Binding"
           type="tns:FrontEndRepository">
    <soap:binding style="document"
                  transport="http://schemas.xmlsoap.org/soap/http"/&gt;
    <operation name="putDocument">
      <soap:operation style="document"
                      soapAction="putDocument"/>
      <input>
        <mime:multipartRelated>
          <mime:part>
            <soap:body use="literal" parts="request"/>
          </mime:part>
          <mime:part>
            <mime:content part="put" type="binary"/>
          </mime:part>
        </mime:multipartRelated>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="FrontEndRepository">
    <port name="FrontEndRepository"
          binding="tns:frontEndRepositoryPortSOAP11Binding">
      <soap:address location="http://localhost:7101/FER-FrontEndrepository-context-root/frontEndRepositoryPort"/&gt;
    </port>
  </service>
</definitions>
+1  A: 

I expect the type attribute in the mime:content element to contain a MIME type, eg. "application/octet-stream", "application/pdf" or "text/plain" rather than "binary".

Using javax.activation.DataHandler should work, and I think you should be able to fix the MIME type of the attachment, and then use a DataHandler instance or a type appropriate to the MIME type (eg. java.awt.Image for "image/jpeg").

You say you have tried a DataHandler, but you haven't provided the exception for that case. If that still fails, what happens when you try it?

janm
I get the same error in all cases.
Phil Wallach
The error was occuring when the service defintion was loaded, not when the operation was invoked. So this needed to be fixed for all definitions in the WSDL.
Phil Wallach