I want to create following xmp using Java soap and I am fresh for this .
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://ift.tt/sVJIaE"
xmlns:xsd="http://ift.tt/tphNwY"
xmlns:xsi="http://ift.tt/ra1lAU">
<SOAP-ENV:Body>
<wst:RequestSecurityToken xmlns:wst="http://ift.tt/16b0Kth
/2005/02/trust">
<wst:RequestType xmlns:wst="http://ift.tt/1iRriz0">
http://ift.tt/16b0Ktn
</wst:RequestType>
<wst:Issuer xmlns:wst="http://ift.tt/1iRriz0">
<wsa:Address xmlns:wsa="http://ift.tt/1LGgXax
/addressing">
urn:ibm:ITFIM:oauth:consumer:YvMhsjmtEEi2gjv8Tqsl
</wsa:Address>
</wst:Issuer>
<wsp:AppliesTo xmlns:wsp="http://ift.tt/Hm2joK">
<wsa:EndpointReference xmlns:wsa="http://ift.tt/1eBVcEY
/ws/2004/08/addressing">
<wsa:Address>http://ift.tt/16b0Ktp
/oauth10</wsa:Address>
</wsa:EndpointReference>
</wsp:AppliesTo>
<wst:Base xmlns:wst="http://ift.tt/1iRriz0">
<stsuuser:STSUniversalUser xmlns:stsuuser="urn:ibm:names:ITFIM
:1.0:stsuuser">
<stsuuser:Principal/>
<stsuuser:AttributeList/>
<stsuuser:ContextAttributes>
<stsuuser:Attribute name="oauth_token"
type="urn:ibm:names:ITFIM:oauth:param">
<stsuuser:Value>YPxa78JggdW7hvcFRJph</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="port"
type="urn:ibm:names:ITFIM:oauth:request">
<stsuuser:Value>9443</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="method"
type="urn:ibm:names:ITFIM:oauth:request">
<stsuuser:Value>POST</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="username"
type="urn:ibm:names:ITFIM:oauth:query:param">
<stsuuser:Value>steve</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="path"
type="urn:ibm:names:ITFIM:oauth:request">
<stsuuser:Value>/fimivt/oauth/sfprotected.jsp
</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="scheme"
type="urn:ibm:names:ITFIM:oauth:request">
<stsuuser:Value>https</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="oauth_nonce"
type="urn:ibm:names:ITFIM:oauth:param">
<stsuuser:Value>xWlY1PbsxjpiSZ4lVGVf</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="host"
type="urn:ibm:names:ITFIM:oauth:request">
<stsuuser:Value>idp.tfim622.com</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="oauth_timestamp"
type="urn:ibm:names:ITFIM:oauth:param">
<stsuuser:Value>1302828764</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="oauth_consumer_key"
type="urn:ibm:names:ITFIM:oauth:param">
<stsuuser:Value>YvMhsjmtEEi2gjv8Tqsl</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="oauth_signature"
type="urn:ibm:names:ITFIM:oauth:param">
<stsuuser:Value>Jpo6apiLE9hVSa8GqBSHUjFt7lg=
</stsuuser:Value>
</stsuuser:Attribute>
<stsuuser:Attribute name="oauth_signature_method"
type="urn:ibm:names:ITFIM:oauth:param">
<stsuuser:Value>HMAC-SHA1</stsuuser:Value>
</stsuuser:Attribute>
</stsuuser:ContextAttributes>
</stsuuser:STSUniversalUser>
</wst:Base>
</wst:RequestSecurityToken>
</soapenv:Body>
</soapenv:Envelope>
I have start to write following code for that
private static SOAPMessage createSOAPRequest() throws Exception {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
String serverURI = "http://ws.cdyne.com4/";
// SOAP Envelope
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("xsd", "http://ift.tt/tphNwY");
envelope.addNamespaceDeclaration("xsi", "http://ift.tt/ra1lAU");
// SOAP Body
SOAPBody soapBody = envelope.getBody();
SOAPElement requestSecurityToken=soapBody.addChildElement("RequestSecurityToken", "wst");
soapMessage.saveChanges();
/* Print the request message */
System.out.print("Request SOAP Message = ");
soapMessage.writeTo(System.out);
System.out.println();
return soapMessage;
}
This code for the only starting of xml and to add that is for the one line inside body
wst:RequestTypeToken xmln:wst="http://ift.tt/1iRriz0">
but it's give follwing error.
Feb 09, 2015 12:25:38 PM com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl addChildElement SEVERE: SAAJ0101: Parent of a SOAPBodyElement has to be a SOAPBody Error occurred while sending SOAP Request to Server com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to locate namespace for prefix wst at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.addChildElement(Unknown Source) at tfimvalidation.ValidateToken.createSOAPRequest(ValidateToken.java:61) at tfimvalidation.ValidateToken.validateToken(ValidateToken.java:20) at Main.main(Main.java:8)
No comments:
Post a Comment