axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Kok <ste...@opensolutions.co.za>
Subject Re: SWA multipart/related boundary
Date Thu, 04 Jan 2007 11:29:16 GMT
Hi 

Please find  code below to reproduce. I am running axis2-1.1.1-SNAPSHOT
from 1 Jan 2007.


public void conHttp() {

try {
/* getSOAP11Factory becuase mm7 spaec says so */
org.apache.axiom.soap.SOAPFactory sf =
OMAbstractFactory.getSOAP11Factory();

SOAPEnvelope env = sf.getDefaultEnvelope();

SOAPHeader sh = env.getHeader();

String nameSpace =
"http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-3";
String prefix = "mm7";

/* create the default namespace for use later */
OMNamespace nms = sf.createOMNamespace("", "");
OMNamespace nmsTranID = sf.createOMNamespace(nameSpace, prefix);

/* set up the header */
OMElement transactionID = sf.createOMElement("TransactionID",
					nmsTranID);

OMAttribute tranIDattrbUnderStand = sf.createOMAttribute(
					"mustUnderstand", nms, "1");

			transactionID.addAttribute(tranIDattrbUnderStand);
transactionID.setText("MyTransaction");
sh.addChild(transactionID);

/* Add body elements here */

SOAPBody sb = env.getBody();

/* SubmitReq */
OMElement sbmtRequest = sf.createOMElement("SubmitRequest", nms);
			sb.addChild(sbmtRequest);

/* MM7Version */
OMElement mm7Version = sf.createOMElement("MM7Version", nms);
sbmtRequest.addChild(mm7Version);
mm7Version.setText("5.3.0");

/* SenderIdentification */
OMElement senderIdentification = sf.createOMElement(
					"SenderIdentification", nms);
sbmtRequest.addChild(senderIdentification);

/* VASPID */
OMElement vasPID = sf.createOMElement("VASPID", nms);
senderIdentification.addChild(vasPID);
			vasPID.setText("XXX");

/* VASID */
OMElement vasID = sf.createOMElement("VASID", nms);
			senderIdentification.addChild(vasID);
			vasID.setText("YYYY");

/* SenderAddress */
OMElement senderAddress = sf.createOMElement("SenderAddress", nms);
			senderIdentification.addChild(senderAddress);

/* RFC2822Address */
OMElement rfc2822Address = sf.createOMElement("RFC2822Address", nms);
OMAttribute rfcAttrb = sf.createOMAttribute("displayOnly", nms,
					"false");
rfc2822Address.addAttribute(rfcAttrb);
senderAddress.addChild(rfc2822Address);
rfc2822Address.setText("12345678901");

/* Recipients */
OMElement recipients = sf.createOMElement("Recipients", nms);
sbmtRequest.addChild(recipients);

/* To */
OMElement to = sf.createOMElement("To", nms);
recipients.addChild(to);

/* Number */
OMElement number = sf.createOMElement("Number", nms);
to.addChild(number);
number.setText("123456789");

/* ServiceCode */
OMElement serviceCode = sf.createOMElement("ServiceCode", nms);
sbmtRequest.addChild(serviceCode);
serviceCode.setText("1");

/* MessageClass */
OMElement messageClass = sf.createOMElement("MessageClass", nms);
			sbmtRequest.addChild(messageClass);
			messageClass.setText("Informational");

/* TimeStamp */
OMElement timeStamp = sf.createOMElement("TimeStamp", nms);
sbmtRequest.addChild(timeStamp);
timeStamp.setText("2006-01-12T09:30:47-05:00");

/* DeliveryReport */
OMElement deliveryReport = sf.createOMElement("DeliveryReport", nms);
sbmtRequest.addChild(deliveryReport);
deliveryReport.setText("false");

/* ReadReply */
OMElement readReply = sf.createOMElement("ReadReply", nms);
sbmtRequest.addChild(readReply);
readReply.setText("false");

/* Priority */
OMElement priority = sf.createOMElement("Priority", nms);
sbmtRequest.addChild(priority);
priority.setText("Normal");
 
/* Subject */
OMElement subject = sf.createOMElement("Subject", nms);
sbmtRequest.addChild(subject);
subject.setText("Welcome to Cell C");
/* Content */
OMElement content = sf.createOMElement("Content", nms);
OMAttribute contentAttrb = sf.createOMAttribute("allowAdaptations",
					nms, "true");
content.addAttribute(contentAttrb);
sbmtRequest.addChild(content);

FileDataSource fileDataSourceImg = new FileDataSource(
	"/home/stefan/workspace/test/bridge.jpg");
FileDataSource fileDataSourceTxt = new FileDataSource(
	"/home/stefan/workspace/test/msg.txt");
FileDataSource fileDataSourceSnd = new FileDataSource(
	"/home/stefan/workspace/test/3475.amr");
					
DataHandler dhImg = new DataHandler(fileDataSourceImg);
DataHandler dhTxt = new DataHandler(fileDataSourceTxt);
DataHandler dhSnd = new DataHandler(fileDataSourceSnd);
		
/*
 * MessageContext
 */
			
MessageContext msgCtx = new MessageContext();
msgCtx.setEnvelope(env);
			
String contentType = msgCtx.addAttachment(dhImg);
content.addAttribute("href", contentType, nms);
		
msgCtx.addAttachment(dhTxt);
msgCtx.addAttachment(dhSnd);
			
			
/*
* Setup the Authentication
 */
List<String> authSchemes = new ArrayList<String>();

HttpTransportProperties.Authenticator auth = new
HttpTransportProperties.Authenticator();
auth.setPreemptiveAuthentication(true);
			authSchemes.add(HttpTransportProperties.Authenticator.DIGEST);
			auth.setAuthSchemes(authSchemes);
			auth.setUsername("username");
			auth.setPassword("password");

/*
 * Set the EndpointReference
 */
EndpointReference epr = new EndpointReference(
					"http://fqdn/mm7");

/*
 * Set the http options
 */

Options httpOptions = new Options();
httpOptions.setTo(epr);
			httpOptions.setProperty(HTTPConstants.AUTHENTICATE, auth);
httpOptions.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
httpOptions.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.FALSE);
httpOptions.setProperty(Constants.Configuration.ENABLE_SWA,
					Constants.VALUE_TRUE);
httpOptions.setProperty(Constants.Configuration.ENABLE_MTOM,
					Constants.VALUE_FALSE);
	
httpOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
//httpOptions
//	.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

/* To set the SOAPAction header to SOAPAction: "" */
httpOptions.setProperty(Constants.Configuration.DISABLE_SOAP_ACTION,
epr);

/*
* ServiceCleint
*/

ServiceClient serviceClient = new ServiceClient(null, null);
serviceClient.setOptions(httpOptions);
serviceClient.addHeader(content);

/**
 * OperationClient
 */
OperationClient mepClient = serviceClient
		.createClient(ServiceClient.ANON_OUT_IN_OP);

mepClient.addMessageContext(msgCtx);

/* for outputting xml documents */

XMLStreamWriter writer;

writer = XMLOutputFactory.newInstance().createXMLStreamWriter(
	System.out);

env.serialize(writer);
writer.flush();
mepClient.execute(true);

			
MessageContext response = mepClient
	.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

SOAPBody body = response.getEnvelope().getBody();
OMElement element = body.getFirstElement().getFirstChildWithName(
					new QName("return"));
System.out.println(element.getText());

} catch (AxisFault e2) {
System.out.println("Axis Fault !!");
e2.printStackTrace();
} catch (FactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XMLStreamException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}





On Thu, 2007-01-04 at 16:37 +0530, Thilina Gunarathne wrote:
> Stefan,
> This message has many errors.. For an example the start field in the
> content type does not match with the content-id of the first MIME
> part.. Also the boundary as you have mentioned..
> 
> Final boundary should be something like the following...
> > --MIMEBoundaryurn_uuid_A9D5ECF2C417B3D84B11678015337975--
> 
> Just now I tested SwA with a simple scenario and it worked fine..
> Please provide more details about your scenario... Also the which
> Axis2 version are you using..
> 
> ~Thilina
> 
> 
> [1]
> >
> > [1] Taken from the header.
> >
> > I have seen many samples with this format. I am not an expert but it
> > seems odd.
> >
> > Kind regards
> > Stefan.
> >
> >
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
> 
> 
-- 
Stefan Kok <stefan@opensolutions.co.za>


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message