Announcement Announcement Module
Collapse
No announcement yet.
Desperate to get this SOAPHeader in place Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Desperate to get this SOAPHeader in place

    Okay, So I have no idea what I am doing, and it's probably all because I am not qualified to be doing all this. But, anyway I want this SOAPHeader:

    <miso-header:SoapHeader xmlns:miso-header="http://www.midwestiso.org/schemas/message/envelope">
    <miso-header:MessageID>12345msg</miso-header:MessageID>
    <miso-header:From>MISO</miso-header:From>
    <miso-header:To>MISO</miso-header:To>
    <miso-header:AuditUser>zachtestclient</miso-header:AuditUser>
    <miso-header:Action>REQUEST</miso-header:Action>
    <miso-header:Category>DATA</miso-header:Category>
    <miso-header:MessageData>
    <miso-header:TimeStamp>2009-04-21T14:42:01.576-04:00</miso-header:TimeStamp>
    <miso-header:TimeToLive>2009-04-21T14:42:01.576-04:00</miso-header:TimeToLive>
    <miso-header:RefToMessageID>0</miso-header:RefToMessageID>
    </miso-header:MessageData>
    <miso-header:Version>miso-message version 1.1</miso-header:Version>
    </miso-header:SoapHeader>


    to be put in with this code:

    Code:
    public class WebServiceClient {
    
    	public ServletContext srvCTX;
        private WebServiceTemplate webServiceTemplate;
        private String _defaultUri;
    
        public void setDefaultUri(String defaultUri) {
            _defaultUri = defaultUri;
        }
    
        public void simpleSendAndReceive(Document doc) {
        	
        	ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(srvCTX);
        	webServiceTemplate = (WebServiceTemplate) context.getBean("webServiceTemplate");
        	webServiceTemplate.setDefaultUri(_defaultUri);
        	System.out.println("in simple...");
            RequestWebServiceMessageCallback test1 = new RequestWebServiceMessageCallback(doc);
            ResponseWebServiceMessageCallback test2 = new ResponseWebServiceMessageCallback();
        	webServiceTemplate.sendAndReceive(test1, test2);
       
        }
    
    
    	class ResponseWebServiceMessageCallback implements WebServiceMessageCallback {
    
    		public ResponseWebServiceMessageCallback() {
    		}
    
    		public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
    			message.writeTo(System.err);
    		}
    	}
        
        
        
        
    	class RequestWebServiceMessageCallback implements WebServiceMessageCallback {
    		private final Document document;
    		
    
    		public RequestWebServiceMessageCallback(Document document) {
    			this.document = document;
    		}
    
    		public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
    			try {
    				SaajSoapMessage saajSoapMessage = (SaajSoapMessage) message;
    				SOAPMessage soapMessage = saajSoapMessage.getSaajMessage();
    				addSoapHeader(soapMessage);
    				addSoapBody(soapMessage);
    			} catch (SOAPException e) {
    				System.out.print("ahh boo");
    			}
    		}
    
    		private void addSoapHeader(SOAPMessage soapMessage) throws SOAPException {
    			SOAPPart soapPart = soapMessage.getSOAPPart();
    			SOAPEnvelope envelope = soapPart.getEnvelope();
    			Name name = envelope.createName("SoapHeader", "miso-header", "http://www.midwestiso.org/schemas/message/envelope");
    			SOAPHeader soapHeader = soapMessage.getSOAPHeader();
    
    			SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement(name);
    			soapHeaderElement.addChildElement("MessageID").setValue("Masg123");
    			
    		}
    
    		private void addSoapBody(SOAPMessage soapMessage) throws SOAPException {
    			Element root = document.getDocumentElement();
    			SOAPBody soapBody = soapMessage.getSOAPBody();
    			soapBody.addDocument(document);
    		}
    	}
    }
    I know my AddSoapHeader method is all jacked up. But I just want that SOAPHeader in there. And frankly I don't understand a lick of any of the documentation on any of this stuff.
Working...
X