java - changing the content-type from application/octet to image/jpeg in MTOM message multipart requeste using jax-ws webservice client -


while using imageupload webservice exposed .net application getting soap fault exception when run generating client wsimport , sending request. whereas soap ui + mtom request works perfect.

my code given below.

public class testclass {     public static void main(string args[]) {         string remoteurl = "myurl";         string port = "";         string imagefilepath = "";         string imagename = "70d08e54-4a5e-4c95-88ba-4c791c2da55e.bmp";         string correlationid = "70fd8ae9-56c9-43b3-b4d9-3d497da05b12";         string createdts = "yyyy-mm-dd't'hh:mm:ss'z'";         string sentts = "yyyy-mm-dd't'hh:mm:ss'z'";         string = "guid";         string messageid = "guid";         string sessionguid = "guid";         try {             url serviceurl = new url(remoteurl);             imagestoreservice iimagestoreservice = new imagestoreservice(                     serviceurl);             iimagestoreservice service = iimagestoreservice                     .getbasichttpbindingiimagestoreservice(new mtomfeature(true));             // cast proxy bindingprovider             bindingprovider bindingprovider = (bindingprovider) service;              objectfactory objectfactory = new objectfactory();             org.datacontract.schemas._2004._07.phoenixinteractive_xpression_common.objectfactory objectfactorycommon = new org.datacontract.schemas._2004._07.phoenixinteractive_xpression_common.objectfactory();             com.microsoft.schemas._2003._10.serialization.objectfactory objectfactoryserialization = new com.microsoft.schemas._2003._10.serialization.objectfactory();              imagestorerequest imagestorerequest = objectfactory.createimagestorerequest();             org.datacontract.schemas._2004._07.phoenixinteractive_xpression_common.imagestorerequest imagestorerequestdata = objectfactorycommon.createimagestorerequest();             messageheader messageheader = objectfactorycommon.createmessageheader();             messageheader.setcorrelationid(correlationid);             simpledateformat sdfcreatedts = new simpledateformat(createdts);             string createdtsdate = sdfcreatedts.format(new date());             simpledateformat sdfsentts = new simpledateformat(sentts);             string senttsdate = sdfsentts.format(new date());             xmlgregoriancalendar cal = datatypefactory.newinstance().newxmlgregoriancalendar(createdtsdate);             xmlgregoriancalendar calsent = datatypefactory.newinstance().newxmlgregoriancalendar(senttsdate);             messageheader.setcreatedts(cal);             messageheader.setfrom(objectfactorycommon.createmessageheaderfrom(from));             messageheader.setmessageid(messageid);             messageheader.setsentts(objectfactorycommon.createmessageheadersentts(calsent));              imagestorerequestdata.setmessageheader(objectfactorycommon.createmessageheader(messageheader));             imagestorerequestdata.setsessionguid(sessionguid);             imagestorerequestdata.setmessagebody(objectfactorycommon.creategenericmessagemessagebody("{"                     + "\"image_upload_data\" : {"                     + " \"session_guid\" : \"guid\", "                     + " \"files\" : { "                     + " \"imagename\" : \"myimagepath\""                     + " } "                     + "}"                 +"}"));              imagedata imgdata = objectfactorycommon.createimagedata();              imgdata.setdata(objectfactoryserialization.createbase64binary(files.readallbytes(paths.get("path","imagename"))));             imgdata.setname(objectfactorycommon.createimagedataname("imagename"));              arrayofimagedata arrayofimagedata = objectfactorycommon.createarrayofimagedata();             list<imagedata> imgdatalist = arrayofimagedata.getimagedata();             imgdatalist.add(imgdata);             imagestorerequestdata.setimagedatalist(objectfactorycommon.createarrayofimagedata(arrayofimagedata));              imagestorerequest.setrequest(objectfactory.createimagestorerequestrequest(imagestorerequestdata));              system.out.println(imagestorerequest.getrequest().getvalue().getimagedatalist());             service.imagestorerequest(imagestorerequestdata);         } catch (exception e) {             e.printstacktrace();             system.out.println("error"+e);         }     }  } 

after sending request multipart of http request shows content-type application/octet want change image/jpeg. tried adding messagecontext.http_request_headers bindingprovider.getrequestcontext() map request content-type still shows applcation/octet.

the wireshark recording given below.

post /serverurl http/1.1 accept: text/xml, multipart/related content-type: multipart/related;start="<rootpart*b1894218-9121-46e1-b3e6-0d966c86ea12@example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:b1894218-9121-46e1-b3e6-0d966c86ea12";start-info="text/xml" soapaction: "" user-agent: jax-ws ri 2.2.4-b01 host: systemtest connection: keep-alive content-length: 37300   --uuid:b1894218-9121-46e1-b3e6-0d966c86ea12 content-id: <rootpart*b1894218-9121-46e1-b3e6-0d966c86ea12@example.jaxws.sun.com> content-type: application/xop+xml;charset=utf-8;type="text/xml" content-transfer-encoding: binary  <?xml version="1.0" ?> <s:envelope>     <s:body>         <ns4:imagestorerequest>             <ns4:request>                 <ns2:messageheader>                     <ns2:correlationid></ns2:correlationid>                     <ns2:createdts></ns2:createdts>                     <ns2:from></ns2:from>                     <ns2:messageid></ns2:messageid>                     <ns2:sentts></ns2:sentts>                 </ns2:messageheader>                 <ns2:messagebody>{json data}</ns2:messagebody>                 <ns2:arrayofimagedata>                     <ns2:imagedata>                         <ns5:base64binary>                             <xop:include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:89fe782f-78f5-4d63-b37d-69131a8df9a3@example.jaxws.sun.com"/>                         </ns5:base64binary>                         <ns2:name></ns2:name>                     </ns2:imagedata>                 </ns2:arrayofimagedata>                 <ns2:sessionguid></ns2:sessionguid>             </ns4:request>         </ns4:imagestorerequest>     </s:body> </s:envelope> --uuid:b1894218-9121-46e1-b3e6-0d966c86ea12 content-id: <89fe782f-78f5-4d63-b37d-69131a8df9a3@example.jaxws.sun.com> content-type: application/octet-stream content-transfer-encoding: binary  exifii*duckyg+http://ns.adobe.com/xap/1.0/<?xpacket begin="" id="w5m0mpcehihzreszntczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="adobe xmp core 5.0-c060 61.134777, 2010/02/12-17:32:00        "> <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:xmpmm="http://ns.adobe.com/xap/1.0/mm/" xmlns:stref="http://ns.adobe.com/xap/1.0/stype/resourceref#" xmp:creatortool="adobe photoshop cs5 macintosh" xmpmm:instanceid="xmp.iid:fc9787c7c6f211e182c9ce33d84e1927" xmpmm:documentid="xmp.did:fc9787c8c6f211e182c9ce33d84e1927"> <xmpmm:derivedfrom stref:instanceid="xmp.iid:fc9787c5c6f211e182c9ce33d84e1927" stref:documentid="xmp.did:fc9787c6c6f211e182c9ce33d84e1927"/> </rdf:description> </rdf:rdf> </x:xmpmeta> <?xpacket end="r"?>&adobed  $@bbb      --uuid:b1894218-9121-46e1-b3e6-0d966c86ea12-- 


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -