Forum Stats

  • 3,853,303 Users
  • 2,264,203 Discussions
  • 7,905,317 Comments

Discussions

SOAP error when sending messages with attachments to a webserice

843834
843834 Member Posts: 49,972
edited Oct 30, 2007 4:05PM in Java Technology & XML
Hi!

im trying to send an ebxml extended soap message to a webservice thats supposed to accept it and send it out, the webservice however thinks that there is a problem with the attachment part of the soap message, if I remove the attachment it works great and there are no reported problems with the soap message.

The message including attachment looks like this:
POST /corvus/httpd/ebms/sender HTTP/1.1
Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Type: multipart/related; type="text/xml"; boundary="----=_Part_0_21356612.1191939936638"
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.6.0_02
Host: 127.0.0.1:9090
Connection: keep-alive
Content-Length: 3310

------=_Part_0_21356612.1191939936638
Content-Type: text/xml; charset=utf-8

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
	<eb:MessageHeader xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope" 
			  xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd" 
			  SOAP:mustUnderstand="1" eb:version="2.0">
	<eb:From>
	<eb:PartyId eb:type="se:foretag1">SEForetag1</eb:PartyId>
	</eb:From>
	<eb:To>
		<eb:PartyId eb:type="se:foretag2">SEForetag2</eb:PartyId>
	</eb:To>
	<eb:CPAId>20071006:SEForetag1:SEForetag2</eb:CPAId>
	<eb:ConversationId>125498SEForetag1</eb:ConversationId>
	<eb:Service>urn:foretag1:services:documentprocessing:NewOrder</eb:Service>
	<eb:Action>incomingNewOrder</eb:Action>
	<eb:MessageData>
		<eb:MessageId>[email protected]</eb:MessageId>
		<eb:Timestamp>1-2-5T10:12:13</eb:Timestamp>
	</eb:MessageData>
	</eb:MessageHeader>
	<eb:AckRequested xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope" 
			 xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd" 
			 SOAP:actor="urn:oasis:names:tc:ebxml-msg:actor:toPartyMSH" SOAP:mustUnderstand="1" 
			 SOAP:signed="false" eb:version="2.0"/>
	<eb:SyncReply xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope" 
		      xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd" 
		      SOAP:actor="http://schemas.xmlsoap.org/soap/actor/next/" SOAP:mustUnderstand="1" 
		      eb:id="" eb:version="2.0"/>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
	<eb:cpaId xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
			   20071006:SEForetag1:SEForetag2</eb:cpaId>
	<eb:service xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
			   urn:foretag1:services:documentprocessing:NewOrder</eb:service>
	<eb:action xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
			   incomingNewOrder</eb:action>
	<eb:convId xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
			   125498SEForetag1</eb:convId>
	<eb:fromPartyId 
		xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
			   SEForetag1</eb:fromPartyId>
	<eb:fromPartyType 
		xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
			   se:foretag1</eb:fromPartyType>
	<eb:toPartyId 
		xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
			   SEForetag2</eb:toPartyId>
	<eb:toPartyType 
	        xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd">
			   se:foretag2</eb:toPartyType>
	<eb:Manifest 
		xmlns:eb="http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd" 
		  	   eb:version="2.0">
	<eb:Reference xmlns:xlink="http://www.w3.org/1999/xlink" 
			   xlink:href="cid:[email protected]" xlink:type="simple">
	<eb:Description xml:lang="se">This is a purchase order.</eb:Description>
	<eb:Schema eb:location="urn:se:foretag1:collaborationprocesses:NewOrder.xsd" 
	  	           eb:version="1.0"/></eb:Reference>
	</eb:Manifest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
------=_Part_0_21356612.1191939936638
Content-Type: text/xml
Content-ID: cid:[email protected]

<order>
	<manufacturer>
	Saw corp
	</manufacturer>
	<item>
	Hell saw
	</item>
	<effect>
	30.00
	</effect>
	<price>
	1000.00
	</price>
	<quantity>
	2
	</quantity>
</order>

------=_Part_0_21356612.1191939936638--
This is the error message the webservice is giving:
2007-10-09 16:25:42 [Thread-741  ] <ERROR> <cecid.ebms.spa> <Error in outbox task>
hk.hku.cecid.ebms.spa.task.MessageValidationException: Cannot reconstruct the message [email protected] from repository
	by com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
	by java.lang.Exception: Missing Start Boundary, or boundary does not start on a new line
	at hk.hku.cecid.ebms.spa.handler.EbxmlMessageDAOConvertor.getEbxmlMessage(EbxmlMessageDAOConvertor.java:373)
	at hk.hku.cecid.ebms.spa.task.OutboxTask.execute(OutboxTask.java:261)
	at hk.hku.cecid.piazza.commons.module.ActiveThread.run(ActiveThread.java:90)
	at java.lang.Thread.run(Thread.java:619)
Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
	at com.sun.xml.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:475)
	at com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:278)
	at com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1_1Impl.java:68)
	at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:62)
	at hk.hku.cecid.ebms.spa.handler.EbxmlMessageDAOConvertor.getEbxmlMessage(EbxmlMessageDAOConvertor.java:367)
	... 3 more
Caused by: java.lang.Exception: Missing Start Boundary, or boundary does not start on a new line
	at com.sun.xml.messaging.saaj.packaging.mime.internet.BMMimeMultipart.getNextPart(BMMimeMultipart.java:237)
	at com.sun.xml.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:429)
	... 7 more
What do you guys think could be the problem?

/Eddie

Edited by: eddie_swe on Oct 9, 2007 8:37 AM

Comments

  • 843834
    843834 Member Posts: 49,972
    Hi,

    I have exactly the same problem.
    			AttachmentPart p = new AttachmentPartImpl();
    			p.setRawContentBytes(byteArray, 0, byteArray.length, "multipart/related");
    			MimeHeaders headers = new MimeHeaders();
    			
    			final Iterator allMimeHeaders = p.getAllMimeHeaders();
    			while(allMimeHeaders.hasNext()) {
    				MimeHeader header = (MimeHeader)allMimeHeaders.next();
    				headers.addHeader(header.getName(), header.getValue());
    			}
    			
    			System.setProperty("javax.xml.soap.MessageFactory", com.sun.xml.internal.messaging.saaj.soap.MessageFactoryImpl.class.getName());
    			MessageFactory factory = MessageFactory.newInstance();
    	        SOAPMessage msg = factory.createMessage(headers, new ByteArrayInputStream(byteArray));
    	        SOAPBody body = msg.getSOAPBody();
    The createMessage fails with
    GRAVE: SAAJ0535: Unable to internalize message
    com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to internalize message
    	at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:475)
    	at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:317)
    	at com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1_1Impl.java:73)
    	at com.sun.xml.internal.messaging.saaj.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:92)
    	at com.xvolks.ws.WSTCPClient.postMessage(WSTCPClient.java:303)
    	at com.xvolks.ws.WSTCPClient.drainSocket(WSTCPClient.java:259)
    	at com.xvolks.ws.WSTCPClient.listen(WSTCPClient.java:233)
    	at com.xvolks.ws.WSTCPClient.access$0(WSTCPClient.java:228)
    	at com.xvolks.ws.WSTCPClient$1.run(WSTCPClient.java:183)
    Caused by: java.lang.Exception: Missing Start Boundary, or boundary does not start on a new line
    	at com.sun.xml.internal.messaging.saaj.packaging.mime.internet.BMMimeMultipart.getNextPart(BMMimeMultipart.java:238)
    	at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.init(MessageImpl.java:429)
    	... 8 more
    The message is : (the content of the soap envelope has been removed for security reason)
    MIME-Version: 1.0
    Content-Type: multipart/related;
    	boundary="[email protected]";
    type="application/xop+xml"; start="<uuid:9accd672-4cbc-364b-a899-ab7a3f3ffc2d>"; start-info="application/soap+xml"
    
    [email protected]
    Content-Type: application/xop+xml;
    type="application/soap+xml"
    Content-Id: <uuid:9accd672-4cbc-364b-a899-ab7a3f3ffc2d>
    Content-Transfer-Encoding: binary
    
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:xop="http://www.w3.org/2004/08/xop/include">...</soap:Envelope>
    [email protected]
  • 843834
    843834 Member Posts: 49,972
    Hi,
    It might be a problem of the factory classes u use for saaj.(especially when using com.sun.xml.*internal*.* implementation classes on the sender side.)

    If u r using Sun's internal implementation saaj factory classes within jre, this kind of errors might occur depending on which version of jre u r using.

    To escape such errors, i suggest u to use stable saaj implementation:
    - 1. Download the latest release of saaj standard implementation from https://saaj.dev.java.net/
    - 2. Replace saaj-api.jar and saaj-impl.jar within the containers u use for both client and server components. (for all of the environments (jre, appserver, other containers...) your applications(client-side, server-side) run through)
    - 3. Be sure that JAVA_HOME/lib/jaxm.properties file does not specify different factory classes. Remove jaxm.properties if it is not intentionally generated.

    Note: saaj1.3 release uses the following jaxm settings:
    - javax.xml.soap.*MessageFactory* = com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
    - javax.xml.soap.*MetaFactory* = com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl
    - javax.xml.soap.*SOAPConnectionFactory* = com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory
    - javax.xml.soap.*SOAPFactory* = com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl

    These steps must resolve the exception. If not, try another implementation such as Axis for saaj, and set factory classes accordingly.

    stanils
    best regards,
This discussion has been closed.