भेजता है मूल रूप से मैं प्रॉक्सी विधि के माध्यम से एक एमटीओएम साबुन संदेश भेजने के लिए एक वेब सेवा क्लाइंट बनाना चाहता हूं। मैंने अपनी सेवा कलाकृतियों को वेब सेवा wsdl से ठीक बनाया है। संदेश सही ढंग से बनाया गया है, हालांकि जब मैं mtom को सक्षम करता हूं और अनुलग्नक जोड़ता हूं, तो अटैचमेंट हमेशा इनलाइन को भेजा जाता है, न कि एक अलग माइम भाग में। इसकी तरह mtom सक्षम है लेकिन किसी कारण से यह संदेश को अनुकूलित नहीं करने का निर्णय लेता है और इसलिए इसे इनलाइन भेजता है। सोपुई के माध्यम से एक ही कोड चलाने से सही परिणाम मिलता है, इसलिए मुझे पता है कि सेवा स्वयं ही स्वीकार करेगी।जेएक्स-डब्ल्यूएस हमेशा एमटीओएम अनुलग्नक इनलाइन
साबुन अनुरोध बनाने और इसे भेजने के लिए मेरा मूल कोड यहां दिया गया है। मैं mtomfeature को सक्षम करता हूं लेकिन soapBinding.setMTOMEnabled(true);
के साथ इसे करने का भी प्रयास किया है, दोनों विधियों के लिए मैंने इसे ((SOAPBinding) binding).isMTOMEnabled()
से डीबग किया है ताकि यह जांच सके कि यह सक्षम होने के लिए सेट है।
// initiate services....
// create service and enable mtom
WebServiceBlah service = new WebServiceBlah(new URL(wsdlURL), SERVICE_NAME);
WebServiceBlahPort port = service.getWebServiceBlahPort(new MTOMFeature(true, 3072));
// load file
File file = new File("/home/mypdf.pdf");
FileInputStream fileinputstream = new FileInputStream(file);
int numberBytes = fileinputstream.available();
byte bytearray[] = new byte[numberBytes];
fileinputstream.read(bytearray);
fileinputstream.close();
// create uploadResult
UploadResult request = new UploadResult();
// create attachment
AttachmentType attachment = new AttachmentType();
attachment.setContentType("application/doc");
attachment.setValue(bytearray);
// create result and add attachment to it
RenderedResult result = new RenderedResult();
result.setResult(attachment);
result.setResultContentType("pdf");
result.setResultName("a pdf file");
// add result to request
request.getResult().add(result);
// send request
port.UploadResults(request);
मुझे जो मिलता है वह मेरा अनुलग्नक नीचे देखा गया है जैसा कि नीचे देखा गया है। (Wireshark साथ कब्जा कर लिया)
POST /blah/ws/ HTTP/1.1
Content-type: multipart/related;start="<rootpart*[email protected]>";type="application/xop+xml";boundary="uuid:15c3ee3b-60c7-4726-a52c-8080965e4536";start-info="text/xml"
Soapaction: ""
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
User-Agent: JAX-WS RI 2.1.6 in JDK 6
Host: 123.123.123.123
Connection: keep-alive
Content-Length: 12372
--uuid:15c3ee3b-60c7-4726-a52c-8080965e4536
Content-Id: <rootpart*[email protected]>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header></S:Header>
<S:Body>
<ns2:uploadResult xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<renderedResult>
<result xmime:contentType="application/doc">JVBERi0xLjQKJaqrrK0KNCAwIG9iago8</result>
<resultContentType>pdf</resultContentType>
<resultName>a pdf file</resultName>
</renderedResult>
</ns2:uploadResult>
</S:Body>
</S:Envelope>
--uuid:15c3ee3b-60c7-4726-a52c-8080965e4536
क्या मैं चाहता हूँ इनलाइन टैग के साथ प्रतिस्थापित किया जाना परिणाम टैग में संलग्न करने के लिए है और लगाव एक अलग माइम भाग में साबुन संदेश में जोड़ा। जैसे
<result xmime:contentType='application/doc'>
<inc:Include href="cid:myid3" xmlns:inc='http://www.w3.org/2004/08/xop/include'/>
</result>
और फिर साबुन संदेश
------=_Part_10_28027205.1314348995670
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: cid:myid3
Content-Disposition: attachment; name="mypdf.pdf"
JVBERi0xLjQKJaqrrK0KNCAwIG9iago8
क्या आपने इसे हल किया? मेरी भी यही समस्या है। जेएक्स-डब्ल्यूएस दस्तावेज यह भी कहता है: 'जैसा कि जेएक्सबी 2.0 विनिर्देश x द्वारा परिभाषित किया गया है: बेस 64 बाइनरी और एक्सएस: जावा में हेक्सबाइनरी मैपिंग बाइट [] है। जेएक्स-डब्ल्यूएस कार्यान्वयन ने बाइट [] आकार के 1 केबी की दहलीज निर्धारित की है। क्लाइंट साइड पर RequestContext में और सर्वर पक्ष पर MessageContext में कार्यान्वयन विशिष्ट गुण com.sun.xml.ws.developer.JAXWSProperties.MTOM_THRESHOLD_VALUE का उपयोग करके इस थ्रेसहोल्ड को संशोधित किया जा सकता है। आप उपरोक्त कोड में थ्रेसहोल्ड को 3072 पर सेट कर रहे हैं। इसे 0,1 पर सेट करना, ... कोई फर्क नहीं पड़ता। – SteveJ