Hi,
I am trying to get the dynamic client to handle attachments for the web
service whose wsdl is attached. I am starting to feel a bit lost...I am
looking for the bit of code that adds attachments to the message object
when the Java stubs are used rather than the dynamic client but I could
not find it. Any help appreciated!
The code I use is:
CXFBusFactory busFactory = new CXFBusFactory();
DynamicClientFactory f =
DynamicClientFactory.newInstance(busFactory.createBus());
Client client =
f.createClient("http://10.14.0.20:8080/soserv/SOConverter?WSDL");
client.getOutInterceptors().add(new
org.apache.cxf.interceptor.LoggingOutInterceptor());
client.getInInterceptors().add(new
org.apache.cxf.interceptor.LoggingInInterceptor());
Object person =
Thread.currentThread().getContextClassLoader().loadClass("soserv.convert
er.types.ConvertMime").newInstance();
Method m = person.getClass().getMethod("setTargetType", String.class);
m.invoke(person, "PDF");
javax.xml.ws.Holder h = new javax.xml.ws.Holder();
h.value = new byte[]{1,2,3};
client.invoke("convertMime", new Object[]{person,h});
INFO: Outbound Message
---------------------------
Encoding: UTF-8
Headers: {SOAPAction=[""], Accept=[*]}
Messages:
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><conve
rtMime
xmlns="urn:soserv:Converter/types"><targetType>PDF</targetType></convert
Mime></soap:Body></soap:Envelope>
--------------------------------------
<<SOConverter.xml>>
Benjamin Coiffe
<?xml version="1.0" encoding="UTF-8"?><!--
Copyright 2005 Sun Microsystems, Inc. All rights reserved.
SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
--><definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 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:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:soserv:Converter/types" xmlns:tns="urn:soserv:Converter/wsdl" targetNamespace="urn:soserv:Converter/wsdl" name="Converter">
<types>
<xsd:schema xmlns:tns="http://ws-i.org/profiles/basic/1.1/xsd" elementFormDefault="qualified" targetNamespace="http://ws-i.org/profiles/basic/1.1/xsd">
<xsd:simpleType name="swaRef">
<xsd:restriction base="xsd:anyURI"/>
</xsd:simpleType>
</xsd:schema>
<xsd:schema xmlns:tns="urn:soserv:Converter/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd" elementFormDefault="qualified" targetNamespace="urn:soserv:Converter/types">
<xsd:complexType name="optionsType">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="value" type="xsd:string"/>
</xsd:complexType>
<!-- struct which holds information related to a conversion job -->
<xsd:element name="convertMime">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="targetType" type="xsd:string" nillable="true"/>
<xsd:element name="option" type="tns:optionsType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="optionString" type="xsd:string" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="convert">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="sourceURL" type="xsd:anyURI" nillable="true"/>
<xsd:element name="sourceDocument" type="xsd:base64Binary" nillable="true"/>
<xsd:element name="wsiAttachment" type="wsi:swaRef" nillable="true"/>
<xsd:element name="targetType" type="xsd:string" nillable="true"/>
<xsd:element name="option" type="tns:optionsType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="optionString" type="xsd:string" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="convertResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="status" type="xsd:string" nillable="true"/>
<xsd:element name="resultURL" type="xsd:anyURI" nillable="true"/>
<xsd:element name="resultDocument" type="xsd:base64Binary" nillable="true"/>
<xsd:element name="wsiAttachment" type="wsi:swaRef" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="convertMimeResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="status" type="xsd:string" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="conversionFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="errorCode" type="xsd:int"/>
<xsd:element name="message" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="convertRequest">
<part name="parameters" element="ns2:convert"/>
</message>
<message name="convertResponse">
<part name="result" element="ns2:convertResponse"/>
</message>
<message name="convertMimeRequest">
<part name="parameters" element="ns2:convertMime"/>
<part name="mimeAttachment" type="xsd:base64Binary"/>
</message>
<message name="convertMimeResponse">
<part name="result" element="ns2:convertMimeResponse"/>
<part name="mimeAttachment" type="xsd:base64Binary"/>
</message>
<message name="conversionError">
<part name="fault" element="ns2:conversionFault"/>
</message>
<!-- service endpoint interface for conversion service -->
<portType name="ConverterSEI">
<operation name="convert">
<documentation>...</documentation>
<input message="tns:convertRequest"/>
<output message="tns:convertResponse"/>
<fault name="conversionError" message="tns:conversionError"/>
</operation>
<operation name="convertMime">
<documentation>...</documentation>
<input message="tns:convertMimeRequest"/>
<output message="tns:convertMimeResponse"/>
<fault name="conversionError" message="tns:conversionError"/>
</operation>
</portType>
<!-- soap binding -->
<binding name="ConverterSEIBinding" type="tns:ConverterSEI">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="convert">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="conversionError">
<soap:fault name="conversionError" use="literal"/>
</fault>
</operation>
<operation name="convertMime">
<soap:operation soapAction=""/>
<input>
<mime:multipartRelated>
<mime:part>
<soap:body use="literal"/>
</mime:part>
<mime:part>
<mime:content part="mimeAttachment" type="application/octet-stream"/>
</mime:part>
</mime:multipartRelated>
</input>
<output>
<mime:multipartRelated>
<mime:part>
<soap:body use="literal"/>
</mime:part>
<mime:part>
<mime:content part="mimeAttachment" type="application/octet-stream"/>
</mime:part>
</mime:multipartRelated>
</output>
<fault name="conversionError">
<soap:fault name="conversionError" use="literal"/>
</fault>
</operation>
</binding>
<service name="Converter">
<port name="ConverterSEIPort" binding="tns:ConverterSEIBinding">
<soap:address location="http://10.14.0.20:8080/soserv/SOConverter" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/>
</port>
</service>
</definitions>