Getting an Invalid or absent Content-Type exception with soap attachment

Hi,
I am trying to send an attachment using Saaj API. As soon as I use the attaachment object and attach it to message I get an exception . If I remove it the over all webservice communication works successfully. Even if I set the content type in the mimeheader explicetely it gives the same error. Any Suggestion how what could be wrong here or how can I fix it please ?
++com.inqmy.lib.jaxm.soap.SAPSoapException: javax.xml.soap.SOAPException: Invalid or absent Content-Type++
++     at com.inqmy.lib.jaxm.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:169)++
++     at com.philips.cms.Main.main(Main.java:261)++
++Caused by: javax.xml.soap.SOAPException: Invalid or absent Content-Type++
++     at com.inqmy.lib.jaxm.soap.SOAPMessageImpl.<init>(SOAPMessageImpl.java:69)++
++     at com.inqmy.lib.jaxm.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:40)++
++     at com.inqmy.lib.jaxm.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:160)++
++     ... 1 more     ++
Below is what the program looks like .
public static void main(String[] args) {
          String nameSpace = "ns";
          String nameSpaceURI = "http://schemas.hp.com/SM/7";
          String comNameSpace = "com";
          String comNameSpaceURI = "http://schemas.hp.com/SM/7/Common";
          String xmNameSpace = "xm";
          String xmNameSpaceURI = "http://www.w3.org/2005/05/xmlmime";
          String endPoint = "http://GBRLONTSYSVW106.code1.emi.philips.com:13088/SM/7/ws";
          try {
                    SOAPConnection soapConnection = SOAPConnectionFactory.newInstance().createConnection();
                    SOAPFactory soapFactory = SOAPFactory.newInstance();
                    MessageFactory messageFactory = MessageFactory.newInstance();
                    // Create a message from the message factory.
                    SOAPMessage soapMessage = messageFactory.createMessage();
               // start: setting HTTP headers - optional, comment out if not needed
                    String username = "BLAH";
                    String password = "****";
                    String authorization = new sun.misc.BASE64Encoder().encode((username+":"+password).getBytes());
                    MimeHeaders hd = soapMessage.getMimeHeaders();
                    hd.removeAllHeaders();
                    hd.addHeader("Authorization", "Basic " + authorization);
                    hd.addHeader("SOAPAction", "Create");
                    // creat a SOAP part have populate the envelope
                    SOAPPart soapPart = soapMessage.getSOAPPart();
                    SOAPEnvelope envelope = soapPart.getEnvelope();
                    envelope.addNamespaceDeclaration(nameSpace, nameSpaceURI);
                    envelope.addNamespaceDeclaration(comNameSpace, comNameSpaceURI);
                    envelope.addNamespaceDeclaration(xmNameSpace, xmNameSpaceURI);
                    // create a SOAP body
                    SOAPBody body = envelope.getBody();
                    Name query = soapFactory.createName("query");
                    Name attachmentInfo = soapFactory.createName("attachmentInfo");
                    Name attachmentData = soapFactory.createName("attachmentData");
                    Name attachments = soapFactory.createName("attachments");
                    Name attachment = soapFactory.createName("attachment");
                    Name model = soapFactory.createName("model");
                    Name keys = soapFactory.createName("keys");
                    Name instance = soapFactory.createName("instance");
                    Name cmsRequestName = envelope.createName( "CreateCaseRequest", nameSpace, nameSpaceURI);
                    SOAPElement soapRequest = body.addBodyElement(cmsRequestName);
                    soapRequest.addAttribute(attachmentInfo, "true");
                    soapRequest.addAttribute(attachmentData, "true");
                    soapRequest.addAttribute(ignoreEmptyElements, "true");
                    SOAPElement soapModel = soapRequest.addChildElement("model",nameSpace, nameSpaceURI);
                    soapModel.addAttribute(query,"?");
                    SOAPElement soapKeys = soapModel.addChildElement("keys",nameSpace, nameSpaceURI);
                    soapKeys.addAttribute(query,"?");
                    SOAPElement soapinstance = soapModel.addChildElement("instance",nameSpace, nameSpaceURI);
                    soapinstance.addAttribute(query,"?");
                    soapinstance.addAttribute(uniquequery,"?");     
                    soapinstance.addAttribute(recordid,"?");
                    SOAPElement soapDescription = soapinstance.addChildElement("Description",nameSpace, nameSpaceURI);
                    SOAPElement soapDescriptionEle = soapDescription.addChildElement("Description",nameSpace, nameSpaceURI);
                    soapDescriptionEle.addTextNode("Test via Saaj");          
                    SOAPElement soapOwnerEle = soapinstance.addChildElement("Owner",nameSpace, nameSpaceURI);
                    soapOwnerEle.addTextNode("INTERFACE");
                    SOAPElement soapTechStatusEle = soapinstance.addChildElement("TechStatus",nameSpace, nameSpaceURI);
                    File file = new File("C:\\Bati\\Phillips\\test case.txt");
                    System.out.println(file.getAbsolutePath());
                    System.out.println(file.getName());
                    System.out.println(file.getPath());
                    FileDataSource ds = new FileDataSource(file);
                    DataHandler dataHandler = new DataHandler(ds);
                    AttachmentPart attachmentPart = soapMessage.createAttachmentPart(dataHandler);
                    attachmentPart.setContentType(dataHandler.getDataSource().getContentType());
                    attachmentPart.setContentId("test");
                    soapMessage.addAttachmentPart(attachmentPart);
                    // set the saves into the structure
                    soapMessage.saveChanges();
                    // output the message
                    System.out.println( "\n============= start request msg ==========\n" );
                    soapMessage.writeTo( System.out );
                    URLEndpoint urlEndpoint = new URLEndpoint(endPoint);
                    System.out.println( "\nSending message to URL: " + urlEndpoint.getURL() );
                    // now make that call over the SOAP connection
                    SOAPMessage reply = soapConnection.call( soapMessage, urlEndpoint );
                    // output the message reply
                    System.out.println( "\n============= start reply ==========\n" );
                    reply.writeTo( System.out );
                    System.out.println( "\n============= end reply ==========\n" );
                    // close down the connection
                    soapConnection.close();
          } catch (Exception ex) {
               ex.printStackTrace();
Thanks,
Bati.

I suppose I should also include the bit where the Servlet actually SENDs the resulting SOAPMessage
SOAPMessage msg = ProcessXML.buildXML(outMessage);
// try to send it
try {
     response.setContentType("text/xml");
     msg.writeTo(response.getOutputStream());

Similar Messages

  • SAAJ0532: Absent Content-Type

    I am using SAAJ in J2EE 1.4 Beta2 to call a web service from a java client. There following is a snap shot of the client code,
    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection connection = soapConnectionFactory.createConnection();
    java.net.URL endpoint = new URL("http://localhost:3456/ws_attachment/ImageService");
    SOAPMessage response = connection.call(message, endpoint);
    I got the following error. Note that message object has the content-type set correctly.
    Thanks.
    Siming
    Aug 22, 2003 5:23:55 PM com.sun.xml.messaging.saaj.soap.MessageImpl <init>
    SEVERE: SAAJ0532: Absent Content-Type
    com.sun.xml.messaging.saaj.SOAPExceptionImpl: Absent Content-Type
    at com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:1
    29)
    at com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1
    _1Impl.java:45)
    at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.crea
    teMessage(SOAPMessageFactory1_1Impl.java:32)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOA
    PConnection.java:361)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedP
    ost.run(HttpSOAPConnection.java:156)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOA
    PConnection.java:126)
    at testwebservice.attachment.saaj.Client.main(Client.java:57)
    java.security.PrivilegedActionException: com.sun.xml.messaging.saaj.SOAPExceptio
    nImpl: Absent Content-Type
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOA
    PConnection.java:126)
    at testwebservice.attachment.saaj.Client.main(Client.java:57)
    Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Absent Content-Type
    at com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:1
    29)
    at
    com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1
    _1Impl.java:45)
    at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.crea
    teMessage(SOAPMessageFactory1_1Impl.java:32)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOA
    PConnection.java:361)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedP
    ost.run(HttpSOAPConnection.java:156)

    Hi friends,
    I have written a servlet to process request and write the XML response.
    I set the content-type of the servlet as "TEXT/XML".
    After running the client program I am getting the following exception.
    SEVERE: SAAJ0532: Absent Content-Type
    com.sun.xml.messaging.saaj.SOAPExceptionImpl: Absent Content-Type
    at com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:129)
    at com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1_1Impl.java:45)
    at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:32)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:361)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:156)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:126)
    at com.griffin.server.manager.processor.cardmarte.CardmarteConnector.call(CardmarteConnector.java:298)
    at com.griffin.server.manager.processor.cardmarte.CardmarteConnector.balanceInquiry(CardmarteConnector.java:199)
    at com.griffin.server.manager.CardManager.executeObtainBalance(CardManager.java:595)
    at com.griffin.server.manager.CardManager.obtainBalance(CardManager.java:534)
    at com.griffin.server.api.http.GetBalanceActor.execute(GetBalanceActor.java:128)
    at com.griffin.server.api.http.RequestActorBase.go(RequestActorBase.java:130)
    at com.griffin.server.api.http.HttpApiController.delegateRequest(HttpApiController.java:239)
    at com.griffin.server.api.http.HttpApiController.doCommon(HttpApiController.java:193)
    at com.griffin.server.api.http.HttpApiController.doPost(HttpApiController.java:159)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    Please help....
    thanks in advance.

  • Trying to Access SharePoint 2013 Rest Api in HTML page but getting Mime Type Exception with Status Success

    I am trying to invoke the SharePoint Rest Api using HTML page. I have included the Access Control Allow Origin to the web.config file. I am getting Readty State 4 and
    Status Success but still I am getting the below error.
    Refused to execute script from 'http://<server>/_api//web/lists?callback=jQuery172045857910416089_1430217181282&_=1430217363882' because its MIME
    type ('application/atom+xml') is not executable, and strict MIME type checking is enabled.
        <script>
            $(document).ready(function () {
                $("#KMPDiscussions").click(function () {
                    //$.support.cors = true;
                    $.ajax({
                        url: "http://<server>/_api//web/lists",
                        dataType: "jsonp",
                        type: "GET",
                        method: "GET",
                        contentType: "application/javascript",
                        headers: {
                            "content-type":
    "application/json;odata=verbose",
                            "accept": "application/json;odata=verbose",
                        success: function onSuccess(data) {
                            alert("Inside Alert");
                        error: function onError(data){
                            alert("Error: "
    + data);
        </script>
    It always hits the error on callback.
    Is there any other way that I can invoke SharePoint Rest Api from a Cross Domain. Please Help.

    Hi Chris,
    Thanks for the reply,Here iam using different files to be uploaded in library.
    please find the below snapshot of json response and ULS logs.
    12/22/2013 18:31:15.02 w3wp.exe (0x3338) 0x401C SharePoint Foundation Files 
    abq2i High Could not get DocumentContent row: 0x80004005. 79f7629c-4694-c026-
    3349-2049178ee919
    12/22/2013 18:31:15.02 w3wp.exe (0x3338) 0x401C SharePoint Foundation Files 
    aiv4w Medium Spent 0 ms to bind -1 byte file stream 79f7629c-4694-c026-3349-
    2049178ee919 
    12/22/2013 18:31:15.02 w3wp.exe (0x3338) 0x401C SharePoint Foundation Files 
    aise3 Medium Failure when fetching document. 0x80070012 79f7629c-4694-c026-
    3349-2049178ee919
    12/22/2013 18:31:15.39 w3wp.exe (0x3338) 0x0D4C SharePoint Foundation 
    Database ab1a9 High Failed to get document content data.
    System.ComponentModel.Win32Exception (0x80004005): Cannot complete this function     at
    Microsoft.SharePoint.SPSqlClient.GetDocumentContentRow(Int32 rowOrd, Object
    ospFileStmMgr, SPDocumentBindRequest& dbreq, SPDocumentBindResults& dbres) 
    79f7629c-76ab-c026-3349-2c9132b13e9a
    12/22/2013 18:31:15.39 w3wp.exe (0x3338) 0x4184 SharePoint Foundation 
    Database ab1a9 High Failed to get document content data.
    System.ComponentModel.Win32Exception (0x80004005): Cannot complete this function     at
    Microsoft.SharePoint.SPSqlClient.GetDocumentContentRow(Int32 rowOrd, Object
    ospFileStmMgr, SPDocumentBindRequest& dbreq, SPDocumentBindResults& dbres) 
    79f7629c-76ab-c026-3349-281167b6cd09
    Thanks again,
    Naresh.

  • Programmatically: Support content types in the gallery and for content types associated with a document library

    Hi there,
    Help appreciated in programmatically 'Supporting content types in the gallery and for content types associated with a document library'.
    Any resources/references or source is greatly appreciated.
    Regards,

    Hi,
    Would you mind providing more details about your requirement? Cause I'm not quite clear about what you really need.
    What’s more, there are seems two questions in your post. If you have several questions to ask, I suggest you post them into every single thread to make them easier to be discussed
    in the forum.
    Best regards
    Patrick Liang
    TechNet Community Support

  • I keep getting "undelivered mail returned to sender" that comes with an attachment. I have not opened the attachment but the email returned is usually from people that i have not emailed in a long time.

    I keep getting "undelivered mail returned to sender" that comes with an attachment. i do not open the attachment but i get email returned from people that i have not emailed in years. I also have current people that tell me they receive email from me and there is nothing on the email and it is a repetative thing for them and for me. I have scanned my computer and it keeps telling me there are no viruses but i keep getting these emails. can anyone help me please!

    Someone is probably sending spam with your address forged on the To: line.  Could be one of your old contacts with a Windows machine has a virus that's doing it.  It's also possible your e-mail account has been hacked, though I'd think such a hacker would be a bit more purposeful.
    For more information, see:
    http://www.reedcorner.net/guides/macvirus/is_it_malware.php#spam
    * Disclaimer: links to my pages may give me compensation, and should not be taken as endorsement of my services by Apple.

  • "Invalid content type" error in SOAP receiver

    Hi ,
    I have ABAP Proxy->XI->Webservice scenario.
    I have configured the SOAP receiver with all neccessary information (Target URL pointing to WSDL , proxy details)
    However i get the following error when i try sending data to the webservice. "Invalid Content type for SOAP: text/html"
    I have seen some forums and blogs on this site on this but still not able to solve the error.
    Please advice...

    Hi Anand,
    Have a look into this thread- similar discussion
    DeliveryException:: invalid content type for SOAP: TEXT/HTML
    Also check this- in the Reciever SOAP Adapter configuration i.e Target URL must be url of the WSDL.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/40728f7b-0401-0010-d9bc-8c73884a3789
    Hope this helps.......
    Regards,
    Abhy

  • How can I get the selected action of content type by javascript from Firefox Options Applications?

    I works on my website, and it have to check the PDF file will be opened in which plugins
    So we have to implement some javascript to check the selected action of Content Type from Tool>Options>Application
    Do we have any javascript code to check this

    You can't check this with code that runs on the server or via JavaScript in the web page.
    Note that current Firefox version do not expose the built-in PDF Reader via the navigator.plugin array, so if you can't detect a plugin than maybe assume that the built-in PDF reader is used with Firefox version 19 and later.
    *Bug 840439 - Expose PDF.JS as a plugin navigator.plugins when enabled

  • ECB Menu item for all CTs (Content Types) except folders (Without hardcoding CT names)

    Hi there,
    How to have an ECB menu item for all items only (and not on Folders).
    I canNOT hardcode the names of Content Types.
    Thanks.

    Have you tried using base content type id?
    http://social.technet.microsoft.com/Forums/en-US/cd63795b-9659-4b35-a023-c007398252a1/hidedisable-ecb-menu-for-particular-selection-in-document-library
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • How to Keep Content Types Current with Updated Data

    Let’s say that I have four content types—content type 1, content type 2, content type 3, and content type 4—all based on the same list, say list A.
    Each content type has its own workflow.
    When the workflow for content type 1 is completed, the data is saved to an individual item, say item Z, in a separate list, list B.
    When the workflow for content type 2 is completed, the data is saved to the same item (item Z) in list B. The reason that there are two lists is that the creation of content types causes new items to be created, but the each
    new item must reference data from the previous item. That means that data has to be copied from the first item to the second item. But what happens to the data in the second item when data from the first item is changed? The solution is to have a single item
    in another list to which all content types write their data.
    What I need to know is how can all the content types retrieve data from list B when those content types are based on list A? For example, let's say that content type 3 uses data originally input through content type 1. As the
    user inputs and saves data through content type 3 he sees data that had been originally input through content type 1. Another user then accesses content type 1 to update and save data through it. When content type 3 is opened again that user will not see the
    updated data entered through content type 1 because it is tied to a different item. The solution seems to be for all content types to save their data to the same item in another list. But then how can those content types be designed so that when they open
    they show updated data from List B when those content types are based on List A?
    Other applications have the notion of a folder containing all the up-to-date data fields. Another way to look at this problem is to state what SharePoint 2007 does to mimic the notion of a folder.

    Thanks for responding, but I don't think that the solution provided solves my problem. What you described will keep the item in List B in sync with the changes made to List A. However, the content types from List A will not be in sync when they are opened
    from List A. Say content type 1 makes changes to various fields. When content type 3 opens it displays some of the fields that content type 1 changed; however, content type 3 and content type 1 by definition display different items--and those items are not
    in sync. Either I have to copy the updated item from List B back to the related items in List A or there has to be another solution.
    Is it possible to have a workflow update all the items in a list based on a key field whenever changes are made to that item. Say content types 1, 2, 3, and 4 already exist and each refers to a different item in List A, but they are "tied" together
    by a key field. When content type 1 is reopened and changes are made, is it possible to iterate over the items in a list to find other items whose key field matches the key field from content type 1? If so, then when matching items are found the fields in
    them can be updated by the same changes made to content type 1.
    If this latter scenario is possible, how is that iteration set up in a SharePoint 2007 workflow? Thanks again.

  • External Content Type (BCS) with a dropdown column choices from a different table

    I want to create an ECT with Create/Update method using SPD.
    The dropdown choices should be also from another table in the database.
    How can I achieve this?
    ----------------------- Sharepoint Newbie

    Hi,
    It is not supported to create External Content Type with a dropdown column by OOTB. 
    For a workaround, you can use Custom Field Controls and jQuery to add
    Drop Down List to External List Form.
    Please take a look at this article
    SP 2010: Customizing the forms for External Lists (BCS) in SharePoint 2010 by using Custom Field Controls and jQuery
    Reference:
    https://social.technet.microsoft.com/Forums/office/en-US/61ffb8a0-af16-4104-94f9-255ea1b8bdf0/dropdown-from-external-content-type?forum=sharepointcustomizationprevious
    Best Regards,
    Eric
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • "Content is not allowed in prolog" with SOAP Attachment

    I'm writing an application using SAAJ that sends a soap message to a servlet which responds with some information, including HTML which the client application will display. The HTML has to go into a SOAP attachment so the tags won't get confused with XML.
    I had the whole thing working with plain text sending within a normal node, and I only switched a few lines to make that text an attachment with HTML instead, but now I'm getting the exception "Content is not allowed in prolog" on the Client side when it tries to create the envelope from the SOAPMessage.
    Code for building answering SOAPMessage with attachment (Servlet to Client)
         public static SOAPMessage buildXML(Message newMessage){
              SOAPMessage msg = null;
              try {
                   MessageFactory msgFactory = MessageFactory.newInstance();
                   msg = msgFactory.createMessage();
                   // Create an envelope in the message
                   SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
                   msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
                   msg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8");
                   //Get hold of the the body
                   SOAPBody body = envelope.getBody();
                   SOAPElement soap_message = body.addChildElement("MESSAGE");
                   if (newMessage.message_type != null){
                        SOAPElement soap_message_type = soap_message.addChildElement("MESSAGETYPE");
                        soap_message_type.addTextNode(newMessage.message_type);
                   if (newMessage.questionID != 0){
                        SOAPElement soap_questionID = soap_message.addChildElement("QUESTIONID");
                        soap_questionID.addTextNode("" + newMessage.questionID);
                   if (newMessage.username != null){
                        SOAPElement soap_username = soap_message.addChildElement("USERNAME");
                        soap_username.addTextNode(newMessage.username);
                   if (newMessage.password != null){
                        SOAPElement soap_password = soap_message.addChildElement("PASSWORD");
                        soap_password.addTextNode(newMessage.password);
                   if (newMessage.message_text != null){
                        AttachmentPart soap_message_text = msg.createAttachmentPart("<html><body>" + newMessage.message_text + "</body></html>", "text/html");
                        soap_message_text.setContentId("MESSAGETEXT");
                        msg.addAttachmentPart(soap_message_text);
                        //SOAPElement soap_message_text = soap_message.addChildElement("MESSAGETEXT");
                        //soap_message_text.addTextNode(newMessage.message_text);
                   if (newMessage.sampleString != null){
                        SOAPElement soap_password = soap_message.addChildElement("SAMPLESTRING");
                        soap_password.addTextNode(newMessage.sampleString);
                   SOAPElement tmpEl;
                   for (int i=0; i<newMessage.numArrayUsed; i++){
                        tmpEl = soap_message.addChildElement("SAMPLEINT");
                        tmpEl.addTextNode("" + newMessage.sampleInt);
                   msg.saveChanges();
              } catch (Exception e) {
                   e.printStackTrace();
              return msg;
    You can see in the area where it adds MESSAGETEXT there are two clients commented out which work. The three lines above it are what changed to make it an attachment instead.
    Code in Client for recieving reply from Servlet
    SOAPMessage reply = connection.call(soap_msg, endpoint);
    System.out.println("\nReceived reply from: " + endpoint);
    reply.writeTo(System.out);
    System.out.println("");
    reply_msg = ProcessXML.parse(reply);This is the console output:
    Edit: These forums seem to be inserting an extra > before the <?xml version="1.0" encoding="UTF-8"?> line, but it doesn't exist in the code I'm pasting
    Received reply from: http://localhost:8080/kuj/CaseStudyServlet
    ------=_Part_2_371807.1137465625031
    Content-Type: text/xml; charset=UTF-8
    <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><MESSAGE><MESSAGETYPE>deliverquestion</MESSAGETYPE><QUESTIONID>1</QUESTIONID><USERNAME>zac</USERNAME></MESSAGE></SOAP-ENV:Body></SOAP-ENV:Envelope>
    ------=_Part_2_371807.1137465625031
    Content-Type: text/html
    Content-Id: MESSAGETEXT
    <html><body>This is an Array sort Question. You will be given 10 random integers and you must sort and return them in the order of greatest to least.</body></html>
    ------=_Part_2_371807.1137465625031--
    ERROR:  'Content is not allowed in prolog.'
    17-Jan-2006 02:40:25 com.sun.xml.messaging.saaj.soap.EnvelopeFactory createEnvelope
    SEVERE: SAAJ0511: Unable to create envelope from given source
    com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:
         at com.sun.xml.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:111)
         at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:39)
         at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:98)
         at com.zacwittedesign.xml.ProcessXML.realParse(ProcessXML.java:32)
         at com.zacwittedesign.xml.ProcessXML.parse(ProcessXML.java:26)
    (snip)And this is the beginning of the code for extracting the info from the SOAPMessage on the Client side:
    private static Message realParse(SOAPMessage msg){
              Message newMessage = new Message();
              try {
                   SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
                   SOAPBody body = envelope.getBody();
    (snip)It dies on SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
    Does anyone know what I'm doing wrong?

    I suppose I should also include the bit where the Servlet actually SENDs the resulting SOAPMessage
    SOAPMessage msg = ProcessXML.buildXML(outMessage);
    // try to send it
    try {
         response.setContentType("text/xml");
         msg.writeTo(response.getOutputStream());

  • Error in soap - Invalid content type

    Hi all
    In soap lookup, i am getting a error that the content type is invalid.
    This is the string from which i have derived the xmlPayload.
    <i><ConversionRate xmlns="http://www.webserviceX.NET/"> <FromCurrency>INR</FromCurrency><ToCurrency>USD</ToCurrency></ConversionRate></i>
    My error message is
    <i>invalid content type for SOAP: TEXT/PLAIN: java.io.IOException: invalid content type for SOAP: TEXT/PLAIN'. Cause Exception: 'invalid content type for SOAP: TEXT/PLAIN'.</i>
    Can someone please suggest me what could have gone wrong?

    url -http://www.webservicex.net/CurrencyConvertor.asmx
    action- http://www.webservicex.net/ConversionRate
    I have enabled Keep headers, Keep attachments, Use query string.
    <b>my code:</b>
    AbstractTrace trace=null;
    try{
    trace=container.getTrace();
    Channel soapChannel=LookupService.getChannel("soaplookup_buss","soap_ib");
    trace.addDebugMessage("channel created");
    SystemAccessor accessor=LookupService.getSystemAccessor(soapChannel);
    trace.addDebugMessage("accessor created");
    String message="<ConversionRate xmlns=\"http://www.webserviceX.NET/\"><FromCurrency>TRY</FromCurrency><ToCurrency>AFA </ToCurrency></ConversionRate>";
    InputStream inputStream = new ByteArrayInputStream(message.getBytes());
    XmlPayload reqPayload = LookupService.getXmlPayload(inputStream);
    Payload resPayload=accessor.call(reqPayload);
    return "success";
    catch(Exception e){
    trace.addDebugMessage("exception occured"+e);
    return "exception occured";

  • How to change data type of content type column.

    Hi all,
    I am having one content type. I have 10 columns in it. There are two rich text columns in my content type. I have attached this content type to pages library. I want to change the data type of this rich text column  to "Full
    HTML content with formatting and constraints for publishing".
    Please assist me with this issue.
    amol

    Hi,
    From your description, my understanding is that you want to change the data type for rich text column in content type.
    The field type of Full HTML content with formatting and constraints for publishing is "Invalid", you could refer to this article:https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldtype.aspx.
    You also could test it by create a Full HTML content with formatting and constraints for publishing column and get the its type with C# code below:
    //change the URL to your SharePoint site
    using (SPSite site = new SPSite("http://sp/sites/sharepoint2013"))
    using (SPWeb web = site.OpenWeb())
    SPFieldType type = web.Fields["Column name"].Type;
    I have tested it with the PowerShell, it cannot hange the rich text column to “Full HTML content with formatting and constraints for publishing” column. If you want to edit the rich text column, you could not change the type of the column as the screenshot
    below:
    As a workaround, you could follow these steps to accomplish your requirement:
    Create a “Full HTML content with formatting and constraints for publishing” type column in the content type.
    Enter your site columns by clicking gear icon -> Site Settings -> Site columns under Web Designer Galleries under section.
    Find and delete the rich text column you want to change.
    Find the column you have created in step 1, and change the column’s name to the name of the text column you have deleted in step 3.
    But you will lose the data of the rich text column in pages library with this method.
    Best Regards,
    Vincent Han
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Powershell to add/delete content type to particular library alone in a site collection

    Hi,
    I am trying to add and delete content type from a particular picture library (site collection) using powershell.
    I have tried the below, but it is not working.
    Below scenarios are not working:
    1) If the content type to be added is there in library, then the loop is still moving to "No content type exists".
    2) Content type is not getting deleted from library
    3) Set the newly added content type as default content type.
    Below is the powershell, which I am trying:
    function ChangeContentType($url)
    $site = Get-SPSite($url);
    $web =$site.RootWeb
    $lookForList = "PicLibrary"
    $lookForCT = "Img1ContentType"
    $lookForRemoveCT = "Image2CT"
    write-host "Checking site:"$web.Title
    #Make sure content types are allowed on the list specified
    $docLibrary = $web.Lists[$lookForList]
    if ($docLibrary -ne $null)
    $docLibrary.ContentTypesEnabled = $true
    $docLibrary.Update()
    if (($web.ContentTypes | where { $web.Name -eq $lookForCT }) -eq $null)
    write-host "No content type exists with the name" $lookForCT "on list" $docLibrary.Title
    #Add site content types to the list
    write-host "Adding content type " $lookForCT "on list" $docLibrary.Title
    $ctToAdd = $web.ContentTypes[$lookForCT]
    $ct = $docLibrary.ContentTypes.Add($ctToAdd)
    write-host "Content type" $ct.Name "added to list" $docLibrary.Title
    $docLibrary.Update();
    else
    write-host "content type exists with the name" $lookForCT "on list" $docLibrary.Title
    #Remove Content type
    if (($web.ContentTypes | where { $web.Name -eq $lookForRemoveCT }) -eq $null)
    write-host "No content type exists with the name" $lookForRemoveCT "on list" $docLibrary.Title
    else
    $ctToRemove = $web.ContentTypes[$lookForRemoveCT]
    write-host "Removing content type" $ctToRemove.Name "from list" $docLibrary.Title
    $docLibrary.ContentTypes.Delete($ctToRemove.Id)
    $docLibrary.Update()
    else
    write-host "The list" $lookForList "does not exist in site" $web.Title
    #Dispose object
    $site.Dispose()
    $web.Dispose()
    How to fix this?
    Thanks

    Hi,
    Thanks for the reply.
    I checked it. If the script is run multiple times, the add and delete content type will throw error.
    How to delete content type? I have tried the below:
    $docLibrary = $web.Lists[$lookForList]
    if ($docLibrary -ne $null)
    $docLibrary.ContentTypesEnabled = $true
    $docLibrary.Update()
    #get the content Type
    Write-host "Getting content type $lookForCT in site $web"
    #Confirm that the content type exists.
    $contentType = $web.ContentTypes | where {$web.ContentTypes.Name -eq $lookForCT}
    ##Abort if not found.
    if ($contentType -eq $null)
    Write-host "$lookForCT not found in site collection."
    else
    if ($web.ContentTypes.Name -eq $lookForCT)
    Write-host $docLibrary.ContentTypes.Name
    if($docLibrary.ContentTypes.Name -eq $lookForCT)
    write-host "Content type $lookForCT is already added to list" $docLibrary.Title
    else
    write-host "No content type exists with the name" $lookForCT "on list" $docLibrary.Title
    write-host "Adding Content Type"
    $ctToAdd = $web.ContentTypes[$lookForCT]
    $ct = $docLibrary.ContentTypes.Add($ctToAdd)
    $docLibrary.Update()
    write-host "Content type" $ct.Name "added to list" $docLibrary.Title
    #get the content Type
    Write-host "Getting content type $lookForRemoveCT in site $web"
    #Confirm that the content type exists.
    $contentType = $web.ContentTypes | where {$web.ContentTypes.Name -eq $lookForRemoveCT}
    ##Abort if not found.
    if ($contentType -eq $null)
    Write-host "$lookForRemoveCT not found in site collection."
    else
    if ($web.ContentTypes.Name -eq $lookForRemoveCT)
    Write-host $docLibrary.ContentTypes.Name
    if($docLibrary.ContentTypes.Name -eq $lookForRemoveCT)
    write-host "Content type $lookForRemoveCT is added to list" $docLibrary.Title.
    write-host "Removing Content type $lookForRemoveCT"
    $ctToRemove = $web.ContentTypes[$lookForRemoveCT]
    $docLibrary.ContentTypes.Delete($ctToRemove.Id)
    $docLibrary.Update()
    else
    write-host "No content type exists with the name" $lookForRemoveCT "on list" $docLibrary.Title
    I am getting error in delete now. Error is "Exception calling "Delete" with "1" argument(s): "Specified argument was out of the range of valid values.
    Parameter name: id"
    Thanks

  • Unsupported response content type "text/html", must be: "tex

    Hi Gurus,
    I'm trying to access a WebService (http://200.68.11.21/WebServices/RecibeMsgSoapISP.wsdl), but I've been facing the following problem below. Could anybody help me?
    //****************************** MY CODE
    FileInputStream file = new FileInputStream("c:\\EXE\\deuda2.xml");
    byte[] bytes = new byte[file.available()];
    file.read(bytes);
    String xml = new String(bytes);
    System.out.println("Xml:\n" + xml);
    URL endPoint =
    new URL(
    "http://200.68.11.21/WebServices/RecibeMsgSoapISP.wsdl");
    Call call = new Call();
    SOAPTransport m_httpConnection =
    new org.apache.soap.transport.http.SOAPHTTPConnection();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("urn:RecibeMsgSoapIsp");
    call.setMethodName("RecibeM2TGR");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
    //SOAPTransport st = new SOAPHTTPConnection();
    //call.setSOAPTransport(st);
    Vector params = new Vector();
    params.addElement(new Parameter("StrXml", String.class, xml, null));
    call.setParams(params);
    //call.setHeader();
    Response response = call.invoke(endPoint, "");
    Parameter result = response.getReturnValue();
    System.out.println("result:" + result);
    //****************************** MY EXCEPTION
    [SOAPException: faultCode=SOAP-ENV:Protocol; msg=Unsupported response content type "text/html", must be: "text/xml". Response was:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <html dir=ltr>
    <head>
    <style> a:link               {font:8pt/11pt verdana; color:FF0000} a:visited          {font:8pt/11pt verdana; color:#4e4e4e}
    </style>
    <META NAME="ROBOTS" CONTENT="NOINDEX">
    <title>No se puede mostrar la p&aacute;gina</title>
    <META HTTP-EQUIV="Content-Type" Content="text-html; charset=Windows-1252">
    </head>
    <script>
    function Homepage(){
    <!--
    // in real bits, urls get returned to our script like this:
    // res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm
         //For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"
         DocURL=document.URL;
         //this is where the http or https will be, as found by searching for :// but skipping the res://
         protocolIndex=DocURL.indexOf("://",4);
         //this finds the ending slash for the domain server
         serverIndex=DocURL.indexOf("/",protocolIndex + 3);
         //for the href, we need a valid URL to the domain. We search for the # symbol to find the begining
         //of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.
         //urlresult=DocURL.substring(protocolIndex - 4,serverIndex);
         BeginURL=DocURL.indexOf("#",1) + 1;
         urlresult=DocURL.substring(BeginURL,serverIndex);
         //for display, we need to skip after http://, and go to the next slash
         displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);
         InsertElementAnchor(urlresult, displayresult);
    function HtmlEncode(text)
    return text.replace(/&/g, &apos;&amp&apos;).replace(/&apos;/g, &apos;&quot;&apos;).replace(/</g, &apos;&lt;&apos;).replace(/>/g, &apos;&gt;&apos;);
    function TagAttrib(name, value)
    return &apos; &apos;+name+&apos;="&apos;+HtmlEncode(value)+&apos;"&apos;;
    function PrintTag(tagName, needCloseTag, attrib, inner){
    document.write( &apos;<&apos; + tagName + attrib + &apos;>&apos; + HtmlEncode(inner) );
    if (needCloseTag) document.write( &apos;</&apos; + tagName +&apos;>&apos; );
    function URI(href)
    IEVer = window.navigator.appVersion;
    IEVer = IEVer.substr( IEVer.indexOf(&apos;MSIE&apos;) + 5, 3 );
    return (IEVer.charAt(1)==&apos;.&apos; && IEVer >= &apos;5.5&apos;) ?
    encodeURI(href) :
    escape(href).replace(/%3A/g, &apos;:&apos;).replace(/%3B/g, &apos;;&apos;);
    function InsertElementAnchor(href, text)
    PrintTag(&apos;A&apos;, true, TagAttrib(&apos;HREF&apos;, URI(href)), text);
    //-->
    </script>
    <body bgcolor="FFFFFF">
    <table width="410" cellpadding="3" cellspacing="5">
    <tr>
    <td align="left" valign="middle" width="360">
         <h1 style="COLOR:000000; FONT: 13pt/15pt verdana"><!--Problem-->No se puede mostrar la p&aacute;gina</h1>
    </td>
    </tr>
    <tr>
    <td width="400" colspan="2"> <font style="COLOR:000000; FONT: 8pt/11pt verdana">No se puede mostrar la p&aacute;gina que est&aacute; buscando porque la direcci&oacute;n de la p&aacute;gina es incorrecta.</font> </td>
    </tr>
    <tr>
    <td width="400" colspan="2"> <font style="COLOR:000000; FONT: 8pt/11pt verdana">
         <hr color="#C0C0C0" noshade>
    <p>Pruebe lo siguiente:</p>
         <ul>
    <li>Si escribi&oacute; la direcci&oacute;n de la p&aacute;gina en la barra de direcciones, compruebe que la ha escrito correctamente.<br>
    </li>
    <li>Abra la p&aacute;gina principal
    <script>
         <!--
         if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))
              Homepage();
         //-->
         </script>
         y busque v&iacute;nculos a la informaci&oacute;n que desee.</li>
    </ul>
    <h2 style="COLOR:000000; FONT: 8pt/11pt verdana">HTTP 405 &ndash; Resource not allowed<br> Servicios de Internet Information Server</h2>
         <hr color="#C0C0C0" noshade>
         <p>Informaci&oacute;n t&eacute;cnica (para personal de soporte)</p>
    <ul>
    <li>M&aacute;s informaci&oacute;n:<br> Soporte t&eacute;cnico de Microsoft
    </li>
    </ul>
    </font></td>
    </tr>
    </table>
    </body>
    </html>
         at org.apache.soap.rpc.Call.getEnvelopeString(Call.java:208)
         at org.apache.soap.rpc.Call.invoke(Call.java:255)
         at test.Test.main(Test.java:42)
    Best regards,
    George

    Is this statement that causes the exception? "Response response = call.invoke(endPoint, "");"
    If so you might be able to catch the SOAPException and interogate the response variable - surround the call with a try, catch block and within the catch you can get the MimeHeaders and check "Content-Type" If it's "text/html" then you know it not a SOAP message so don't use the SOAP api calls.
    It sounds like the web service is offline and the web server is trying to send you an HTML error page which of course is not a SOAP message and so a SOAPException is thrown.

Maybe you are looking for

  • How to display the data in PDF format : problem is splitting into 2 lines

    Hi , I developed one report which downloads the data into PDF format and saved in C drive but my problem is in my program : Line size of the report is 255 in PDF it is splitting into 2 lines. it has to show in a single line. how to do it. how to redu

  • Total Amount Calculation Error

    This is for a total field.   I have created a purchase req that calculates a total for each line.  This is working fine.  What I want to do is create a total field of all the individual; lines on the page and list this as a read-only field at the bot

  • How Do I Get Home Videos into iTunes?

    I have 6 home videos that I want to put into iTunes....both the iTunes library on the hard drive and the iTunes app.  I had them in there but for some reason they got mixed up and I deleted them. I have the copies so how do I get them into the iTunes

  • Can not get web part to stay minimized

    We have a team site with many web parts on the page many being different calendars. Most the the web part we have set to be minimized. We add a new web part and set it to be minimized by default in the web part settings, as well as clicked the option

  • Change in budget Upload Format

    Hi, we need a way to be able to do a plan/actual comparison down to material level? Please can someone suggest me if this is possible by any means? Regards, Parul