1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.support.wsrm;
14
15 import org.apache.xmlbeans.XmlCursor;
16 import org.apache.xmlbeans.XmlObject;
17
18 import net.java.dev.wadl.x2009.x02.ApplicationDocument;
19
20 public class WsrmBuilder
21 {
22 private static final String WSRM_CREATE_SEQUENCE = "CreateSequence";
23 private static final String WSRM_EXPIRES = "Expires";
24 private static final String WSRM_ACKNOWLEDGMENTS_TO = "AcksTo";
25
26 private static final String WSRM_CLOSE_SEQUENCE = "CloseSequence";
27 private static final String WSRM_IDENTIFIER = "Identifier";
28 private static final String WSRM_LAST_MESSAGE = "LastMsgNumber";
29
30 private WsrmConfig wsrmConfig;
31
32 public WsrmBuilder( WsrmConfig wsrmConfig )
33 {
34 this.wsrmConfig = wsrmConfig;
35 }
36
37 public XmlObject constructSequenceRequest()
38 {
39 XmlObject object = XmlObject.Factory.newInstance();
40 XmlCursor cursor = object.newCursor();
41
42
43 cursor.insertNamespace( "wsrm", wsrmConfig.getVersionNameSpace() );
44
45 cursor.beginElement( WSRM_CREATE_SEQUENCE, wsrmConfig.getVersionNameSpace() );
46 cursor.insertElementWithText( WSRM_ACKNOWLEDGMENTS_TO, wsrmConfig.getAckTo() );
47 if( wsrmConfig.getSequenceExpires() != null )
48 cursor.insertElementWithText( WSRM_EXPIRES, wsrmConfig.getSequenceExpires().toString() );
49
50 cursor.dispose();
51
52 return object;
53 }
54
55 public XmlObject constructSequenceClose()
56 {
57 XmlObject object = XmlObject.Factory.newInstance();
58 XmlCursor cursor = object.newCursor();
59 cursor.toNextToken();
60
61 cursor.insertNamespace( "wsrm", wsrmConfig.getVersionNameSpace() );
62
63 cursor.beginElement( WSRM_CLOSE_SEQUENCE, wsrmConfig.getVersionNameSpace() );
64 cursor.insertElementWithText( WSRM_IDENTIFIER, wsrmConfig.getSequenceIdentifier() );
65
66 cursor.insertElementWithText( WSRM_LAST_MESSAGE, "1" );
67
68 cursor.dispose();
69
70 return object;
71 }
72 }