sockets - How to send raw SOAP request in Java? -


i need send raw soap request server. request looks

post http://10.76.243.43:8080/registry/services/xds-iti18 http/1.1 accept-encoding: gzip,deflate content-type: application/soap+xml;charset=utf-8 content-length: 6383 host: 10.76.243.43:8080 connection: keep-alive user-agent: apache-httpclient/4.1.1 (java 1.5)  <soap:envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0" xmlns:urn1="urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0" xmlns:urn2="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0">    <soap:header/>    <soap:body>       <urn:adhocqueryrequest id="?" comment="?" federated="false" federation="?" startindex="0" maxresults="-1">          <!--optional:-->          <urn1:requestslotlist>             <!--zero or more repetitions:-->             <urn2:slot name="?" slottype="?">                <urn2:valuelist>                   <urn2:value>?</urn2:value>                </urn2:valuelist>             </urn2:slot>          </urn1:requestslotlist>          <urn:responseoption returntype="registryobject" returncomposedobjects="false"/>          <urn2:adhocquery id="?" home="?" lid="?" objecttype="?" status="?">             <!--zero or more repetitions:-->             <urn2:slot name="?" slottype="?">                <urn2:valuelist>                   <urn2:value>?</urn2:value>                </urn2:valuelist>             </urn2:slot>             <!--optional:-->             <urn2:name>                <urn2:localizedstring xml:lang="en-us" charset="utf-8" value="?"/>             </urn2:name>             <!--optional:-->             <urn2:description>                <urn2:localizedstring xml:lang="en-us" charset="utf-8" value="?"/>             </urn2:description>             <!--optional:-->             <urn2:versioninfo versionname="1.1" comment="?"/>             <!--zero or more repetitions:-->             <urn2:classification id="?" home="?" lid="?" objecttype="?" status="?" classificationscheme="?" classifiedobject="?" classificationnode="?" noderepresentation="?">                <!--zero or more repetitions:-->                <urn2:slot name="?" slottype="?">                   <urn2:valuelist>                      <urn2:value>?</urn2:value>                   </urn2:valuelist>                </urn2:slot>                <!--optional:-->                <urn2:name>                   <urn2:localizedstring xml:lang="en-us" charset="utf-8" value="?"/>                </urn2:name>                <!--optional:-->                <urn2:description>                   <urn2:localizedstring xml:lang="en-us" charset="utf-8" value="?"/>                </urn2:description>                <!--optional:-->                <urn2:versioninfo versionname="1.1" comment="?"/>                <!--zero or more repetitions:-->                <urn2:classification/>                <!--zero or more repetitions:-->                <urn2:externalidentifier id="?" home="?" lid="?" objecttype="?" status="?" registryobject="?" identificationscheme="?" value="?">                   <!--zero or more repetitions:-->                   <urn2:slot name="?" slottype="?">                      <urn2:valuelist>                         <urn2:value>?</urn2:value>                      </urn2:valuelist>                   </urn2:slot>                   <!--optional:-->                   <urn2:name>                      <urn2:localizedstring xml:lang="en-us" charset="utf-8" value="?"/>                   </urn2:name>                   <!--optional:-->                   <urn2:description>                      <urn2:localizedstring xml:lang="en-us" charset="utf-8" value="?"/>                   </urn2:description>                   <!--optional:-->                   <urn2:versioninfo versionname="1.1" comment="?"/>                   <!--zero or more repetitions:-->                   <urn2:classification/>                   <!--zero or more repetitions:-->                   <urn2:externalidentifier/>                </urn2:externalidentifier>             </urn2:classification>             <!--zero or more repetitions:-->             <urn2:externalidentifier id="?" home="?" lid="?" objecttype="?" status="?" registryobject="?" identificationscheme="?" value="?">                <!--zero or more repetitions:-->                <urn2:slot name="?" slottype="?">                   <urn2:valuelist>                      <urn2:value>?</urn2:value>                   </urn2:valuelist>                </urn2:slot>                <!--optional:-->                <urn2:name>                   <urn2:localizedstring xml:lang="en-us" charset="utf-8" value="?"/>                </urn2:name>                <!--optional:-->                <urn2:description>                   <urn2:localizedstring xml:lang="en-us" charset="utf-8" value="?"/>                </urn2:description>                <!--optional:-->                <urn2:versioninfo versionname="1.1" comment="?"/>                <!--zero or more repetitions:-->                <urn2:classification id="?" home="?" lid="?" objecttype="?" status="?" classificationscheme="?" classifiedobject="?" classificationnode="?" noderepresentation="?">                   <!--zero or more repetitions:-->                   <urn2:slot name="?" slottype="?">                      <urn2:valuelist>                         <urn2:value>?</urn2:value>                      </urn2:valuelist>                   </urn2:slot>                   <!--optional:-->                   <urn2:name>                      <urn2:localizedstring xml:lang="en-us" charset="utf-8" value="?"/>                   </urn2:name>                   <!--optional:-->                   <urn2:description>                      <urn2:localizedstring xml:lang="en-us" charset="utf-8" value="?"/>                   </urn2:description>                   <!--optional:-->                   <urn2:versioninfo versionname="1.1" comment="?"/>                   <!--zero or more repetitions:-->                   <urn2:classification/>                   <!--zero or more repetitions:-->                   <urn2:externalidentifier/>                </urn2:classification>                <!--zero or more repetitions:-->                <urn2:externalidentifier/>             </urn2:externalidentifier>             <!--optional:-->             <urn2:queryexpression querylanguage="?">                e                <!--you may enter elements @ point-->                gero             </urn2:queryexpression>          </urn2:adhocquery>       </urn:adhocqueryrequest>    </soap:body> </soap:envelope> 

it standard raw request generated soap ui (using wsdl of web service), if send there http code 200 , normal response. want send using java, following

byte[] encoded = files.readallbytes(paths.get("c:\\users\\timofb\\documents\\testtest.txt"));//file raw request string soapxml = new string(encoded, standardcharsets.utf_8); socket socket = new socket("10.76.243.43", 8080); bufferedwriter out = new bufferedwriter(             new outputstreamwriter(socket.getoutputstream(), "utf8")); bufferedreader in = new bufferedreader(             new inputstreamreader(socket.getinputstream())); out.write(soapxml); out.flush(); system.out.println("\n * response");     string line; while ((line = in.readline()) != null) {      system.out.println(line); } in.close(); 

i http status 500 , soap message fault occurred while processing. thanks.

i've found answer. code worked me

    byte[] encoded = files.readallbytes(paths.get("c:\\users\\timofb\\documents\\test.txt"));     string soapxml = new string(encoded, standardcharsets.utf_8);     soapconnectionfactory soapconnectionfactory =             soapconnectionfactory.newinstance();     java.net.url endpoint = new url("http://" + ip + "/cs-repository/services/xds-iti41");     soapconnection connection = soapconnectionfactory.createconnection();     messagefactory factory = messagefactory.newinstance();     soapmessage message = factory.createmessage(new mimeheaders(), new bytearrayinputstream(encoded));     attachmentpart attachment = message.createattachmentpart();     attachment.setcontent("sm_content", "text/plain");     attachment.setcontentid("1.9f910338bf0cac0e783bfdec7e53be9237684caa8f8f4e6d@apache.org");     message.addattachmentpart(attachment);     soapmessage response = connection.call(message, endpoint);     bytearrayoutputstream out = new bytearrayoutputstream();     response.writeto(out);     string strmsg = new string(out.tobytearray());     return strmsg; 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -