Home » Developer & Programmer » JDeveloper, Java & XML » Attachment problem (Oracle SQL Developer 3.0.04 , jdeveloper 11g R1 11.1.1.4.0, Win7, Weblogic server)
|
|
|
Re: Attachment problem [message #530807 is a reply to message #530781] |
Thu, 10 November 2011 13:11 |
|
Barbara Boehmer
Messages: 9103 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
The following is the contents of the hmm.txt attachment, with code tags:
package mypacked;
import java.math.BigDecimal;
import javax.activation.DataHandler;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlMimeType;
import javax.xml.ws.BindingType;
import javax.xml.ws.soap.MTOM;
import javax.xml.ws.soap.SOAPBinding;
@WebService(targetNamespace = "http...tempuri.org", portName = "TestWSSoap12HttpPort") // NOT SURE WHAT TO DO HERE ?
@BindingType(SOAPBinding.SOAP12HTTP_BINDING) // NOT SURE IS THIS CORRECT ?
@MTOM // CAN I USE THIS IN MY VERSION AND WITH JAX-RPC ?
public class upload_file {
@WebMethod
public BigDecimal createJournal(@WebParam(name = "journal") String journal) {
return null ;
}
@WebMethod
public void attachFile(
@WebParam(name = "id") BigDecimal id,
@WebParam(name = "filename") BigDecimal filename,
@WebParam(name = "data") @XmlMimeType("application/octet-stream") DataHandler data) {
}
}
-------------------------------------------------------------------------------------------------
create or replace
PACKAGE BODY JANIS AS
function upload_file(session_id in number, upload_id in number)
return xmltype
AS
temp varchar2(4000);
crlf char(2):=chr(13)||chr(10);
BEGIN
if upload_id is null then
raise_application_error(-20032,'');
end if;
temp:='<definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://attachment.tip/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://attachment.tip/">'||crlf;
temp:=temp||' <types/>'||crlf;
temp:=temp||' <message name="sendImage">'||crlf;
temp:=temp||' <part name="image" type="xsd:base64Binary"/>'||crlf;
temp:=temp||' </message>'||crlf;
temp:=temp||' <message name="sendImageResponse"/>'||crlf;
temp:=temp||' <message name="sendOctet">'||crlf;
temp:=temp||' <part name="octet" type="xsd:base64Binary"/>'||crlf;
temp:=temp||' </message>'||crlf;
temp:=temp||' <message name="sendOctetResponse"/>'||crlf;
temp:=temp||' <portType name="AttachmentTip">'||crlf;
temp:=temp||' <operation name="sendImage">'||crlf;
temp:=temp||' <input message="tns:sendImage"/>'||crlf;
temp:=temp||' <output message="tns:sendImageResponse"/>'||crlf;
temp:=temp||' </operation>'||crlf;
temp:=temp||' <operation name="sendOctet">'||crlf;
temp:=temp||' <input message="tns:sendOctet"/>'||crlf;
temp:=temp||' <output message="tns:sendOctetResponse"/>'||crlf;
temp:=temp||' </operation>'||crlf;
temp:=temp||' </portType>'||crlf;
temp:=temp||' <binding name="AttachmentBinding" type="tns:AttachmentTip">'||crlf;
temp:=temp||' <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>'||crlf;
temp:=temp||' <operation name="sendImage">'||crlf;
temp:=temp||' <soap:operation soapAction=""/>'||crlf;
temp:=temp||' <input>'||crlf;
temp:=temp||' <mime:multipartRelated>'||crlf;
temp:=temp||' <mime:part>'||crlf;
temp:=temp||' <soap:body parts="" namespace="http://attachment.tip/" use="literal"/>'||crlf;
temp:=temp||' </mime:part>'||crlf;
temp:=temp||' <mime:part>'||crlf;
temp:=temp||' <mime:content part="image" type="image/jpeg"/>'||crlf;
temp:=temp||' </mime:part>'||crlf;
temp:=temp||' </mime:multipartRelated>'||crlf;
temp:=temp||' </input>'||crlf;
temp:=temp||' <output>'||crlf;
temp:=temp||' <soap:body namespace="http://attachment.tip/" use="literal"/>'||crlf;
temp:=temp||' </output>'||crlf;
temp:=temp||' </operation>'||crlf;
temp:=temp||' <operation name="sendOctet">'||crlf;
temp:=temp||' <soap:operation soapAction=""/>'||crlf;
temp:=temp||' <input>'||crlf;
temp:=temp||' <mime:multipartRelated>'||crlf;
temp:=temp||' <mime:part>'||crlf;
temp:=temp||' <soap:body parts="" namespace="http://attachment.tip/" use="literal"/>'||crlf;
temp:=temp||' </mime:part>'||crlf;
temp:=temp||' <mime:part>'||crlf;
temp:=temp||' <mime:content part="octet" type="application/octet-stream"/>'||crlf;
temp:=temp||' </mime:part>'||crlf;
temp:=temp||' </mime:multipartRelated>'||crlf;
temp:=temp||' </input>'||crlf;
temp:=temp||' <output>'||crlf;
temp:=temp||' <soap:body namespace="http://attachment.tip/" use="literal"/>'||crlf;
temp:=temp||' </output>'||crlf;
temp:=temp||' </operation>'||crlf;
temp:=temp||' </binding>'||crlf;
temp:=temp||' <service name="AttachmentService">'||crlf;
temp:=temp||' <port binding="tns:AttachmentBinding" name="AttachmentTip">'||crlf;
temp:=temp||' <soap:address location="http://localhost:9080/SwAService/services/AttachmentTip"/>'||crlf;
temp:=temp||' </port>'||crlf;
temp:=temp||' </service>'||crlf;
temp:=temp||' </definitions>'||crlf;
return (xmltype(temp));
exception
when others then
if sqlcode=-20031 then
raise_application_error(-20031,'...');
elsif sqlcode=-20032 then
raise_application_error(-20032,'...');
elsif sqlcode=-20033 then
raise_application_error(-20033,'...');
elsif sqlcode=-20036 then
raise_application_error(-20036,'...');
else
raise_application_error(-20099,'...');
end if;
END upload_file;
END JANIS;
|
|
|
Re: Attachment problem [message #530809 is a reply to message #530807] |
Thu, 10 November 2011 13:22 |
|
Barbara Boehmer
Messages: 9103 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
Assuming that you have a valid package specification for the janis package, as I have provided below, then your package body compiles without error and the function executes without error and appears to return a valid xmltype. So, if you are having a problem it must be in the java. I will move this from the SQL and PL/SQL sub-forum to the sub-forum for JAVA and XML.
SCOTT@orcl_11gR2> create or replace PACKAGE JANIS
2 AS
3 function upload_file(session_id in number, upload_id in number)
4 return xmltype;
5 END JANIS;
6 /
Package created.
SCOTT@orcl_11gR2> show errors
No errors.
SCOTT@orcl_11gR2> create or replace PACKAGE BODY JANIS
2 AS
3 function upload_file(session_id in number, upload_id in number)
4 return xmltype
5 AS
6 temp varchar2(4000);
7 crlf char(2):=chr(13)||chr(10);
8 BEGIN
9
10 if upload_id is null then
11 raise_application_error(-20032,'');
12 end if;
13
14 temp:='<definitions
15 xmlns="http://schemas.xmlsoap.org/wsdl/"
16 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
17 xmlns:tns="http://attachment.tip/"
18 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
19 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
20 targetNamespace="http://attachment.tip/">'||crlf;
21 temp:=temp||' <types/>'||crlf;
22 temp:=temp||' <message name="sendImage">'||crlf;
23 temp:=temp||' <part name="image" type="xsd:base64Binary"/>'||crlf;
24 temp:=temp||' </message>'||crlf;
25 temp:=temp||' <message name="sendImageResponse"/>'||crlf;
26 temp:=temp||' <message name="sendOctet">'||crlf;
27 temp:=temp||' <part name="octet" type="xsd:base64Binary"/>'||crlf;
28 temp:=temp||' </message>'||crlf;
29 temp:=temp||' <message name="sendOctetResponse"/>'||crlf;
30 temp:=temp||' <portType name="AttachmentTip">'||crlf;
31 temp:=temp||' <operation name="sendImage">'||crlf;
32 temp:=temp||' <input message="tns:sendImage"/>'||crlf;
33 temp:=temp||' <output message="tns:sendImageResponse"/>'||crlf;
34 temp:=temp||' </operation>'||crlf;
35 temp:=temp||' <operation name="sendOctet">'||crlf;
36 temp:=temp||' <input message="tns:sendOctet"/>'||crlf;
37 temp:=temp||' <output message="tns:sendOctetResponse"/>'||crlf;
38 temp:=temp||' </operation>'||crlf;
39 temp:=temp||' </portType>'||crlf;
40 temp:=temp||' <binding name="AttachmentBinding" type="tns:AttachmentTip">'||crlf;
41 temp:=temp||' <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>'||crlf;
42 temp:=temp||' <operation name="sendImage">'||crlf;
43 temp:=temp||' <soap:operation soapAction=""/>'||crlf;
44 temp:=temp||' <input>'||crlf;
45 temp:=temp||' <mime:multipartRelated>'||crlf;
46 temp:=temp||' <mime:part>'||crlf;
47 temp:=temp||' <soap:body parts="" namespace="http://attachment.tip/" use="literal"/>'||crlf;
48 temp:=temp||' </mime:part>'||crlf;
49 temp:=temp||' <mime:part>'||crlf;
50 temp:=temp||' <mime:content part="image" type="image/jpeg"/>'||crlf;
51 temp:=temp||' </mime:part>'||crlf;
52 temp:=temp||' </mime:multipartRelated>'||crlf;
53 temp:=temp||' </input>'||crlf;
54 temp:=temp||' <output>'||crlf;
55 temp:=temp||' <soap:body namespace="http://attachment.tip/" use="literal"/>'||crlf;
56 temp:=temp||' </output>'||crlf;
57 temp:=temp||' </operation>'||crlf;
58 temp:=temp||' <operation name="sendOctet">'||crlf;
59 temp:=temp||' <soap:operation soapAction=""/>'||crlf;
60 temp:=temp||' <input>'||crlf;
61 temp:=temp||' <mime:multipartRelated>'||crlf;
62 temp:=temp||' <mime:part>'||crlf;
63 temp:=temp||' <soap:body parts="" namespace="http://attachment.tip/" use="literal"/>'||crlf;
64 temp:=temp||' </mime:part>'||crlf;
65 temp:=temp||' <mime:part>'||crlf;
66 temp:=temp||' <mime:content part="octet" type="application/octet-stream"/>'||crlf;
67 temp:=temp||' </mime:part>'||crlf;
68 temp:=temp||' </mime:multipartRelated>'||crlf;
69 temp:=temp||' </input>'||crlf;
70 temp:=temp||' <output>'||crlf;
71 temp:=temp||' <soap:body namespace="http://attachment.tip/" use="literal"/>'||crlf;
72 temp:=temp||' </output>'||crlf;
73 temp:=temp||' </operation>'||crlf;
74 temp:=temp||' </binding>'||crlf;
75 temp:=temp||' <service name="AttachmentService">'||crlf;
76 temp:=temp||' <port binding="tns:AttachmentBinding" name="AttachmentTip">'||crlf;
77 temp:=temp||' <soap:address location="http://localhost:9080/SwAService/services/AttachmentTip"/>'||crlf;
78 temp:=temp||' </port>'||crlf;
79 temp:=temp||' </service>'||crlf;
80 temp:=temp||' </definitions>'||crlf;
81
82 return (xmltype(temp));
83
84 exception
85 when others then
86 if sqlcode=-20031 then
87 raise_application_error(-20031,'...');
88 elsif sqlcode=-20032 then
89 raise_application_error(-20032,'...');
90 elsif sqlcode=-20033 then
91 raise_application_error(-20033,'...');
92 elsif sqlcode=-20036 then
93 raise_application_error(-20036,'...');
94 else
95 raise_application_error(-20099,'...');
96 end if;
97
98 END upload_file;
99 END JANIS;
100 /
Package body created.
SCOTT@orcl_11gR2> show errors
No errors.
SCOTT@orcl_11gR2> select janis.upload_file (1, 1)
2 from dual
3 /
JANIS.UPLOAD_FILE(1,1)
--------------------------------------------------------------------------------
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas
.xmlsoap.org/wsdl/soap/" xmlns:tns="http://attachment.tip/" xmlns:xsd="http://ww
w.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targ
etNamespace="http://attachment.tip/">
<types/>
<message name="sendImage">
<part name="image" type="xsd:base64Binary"/>
</message>
<message name="sendImageResponse"/>
<message name="sendOctet">
<part name="octet" type="xsd:base64Binary"/>
</message>
<message name="sendOctetResponse"/>
<portType name="AttachmentTip">
<operation name="sendImage">
<input message="tns:sendImage"/>
<output message="tns:sendImageResponse"/>
</operation>
<operation name="sendOctet">
<input message="tns:sendOctet"/>
<output message="tns:sendOctetResponse"/>
</operation>
</portType>
<binding name="AttachmentBinding" type="tns:AttachmentTip">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sendImage">
<soap:operation soapAction=""/>
<input>
<mime:multipartRelated>
<mime:part>
<soap:body parts="" namespace="http://attachment.tip/" use="literal"
/>
</mime:part>
<mime:part>
<mime:content part="image" type="image/jpeg"/>
</mime:part>
</mime:multipartRelated>
</input>
<output>
<soap:body namespace="http://attachment.tip/" use="literal"/>
</output>
</operation>
<operation name="sendOctet">
<soap:operation soapAction=""/>
<input>
<mime:multipartRelated>
<mime:part>
<soap:body parts="" namespace="http://attachment.tip/" use="literal"
/>
</mime:part>
<mime:part>
<mime:content part="octet" type="application/octet-stream"/>
</mime:part>
</mime:multipartRelated>
</input>
<output>
<soap:body namespace="http://attachment.tip/" use="literal"/>
</output>
</operation>
</binding>
<service name="AttachmentService">
<port binding="tns:AttachmentBinding" name="AttachmentTip">
<soap:address location="http://localhost:9080/SwAService/services/Attachme
ntTip"/>
</port>
</service>
</definitions>
1 row selected.
SCOTT@orcl_11gR2>
|
|
|
|
|
Goto Forum:
Current Time: Sun Jan 26 00:55:07 CST 2025
|