Cisco Cisco Prime Network 4.0 Entwickleranleitung

Seite von 148
       Appendix II – 3GPP-Miscellaneous
 
 
Cisco Prime Network OSS  Integration  Guide for  MTOSI and 3GPP 
OL-30201-01
 
 
143 
11.7 Useful Code Snippets for 3GPP 
This section has sample code snippets to retrieve the inventory using 3GPP interface. 
11.7.1 Code Snippet for 3GPP Request Response 
 
This section provides code snippets that can be used by a SOAP client to communicate with 
the 3GPP Web Service to perform the required operation.
 
 
// Java SOAP client Imports 
 
import javax.xml.soap.SOAPBody; 
import javax.xml.soap.SOAPConnection; 
import javax.xml.soap.SOAPConnectionFactory; 
import javax.xml.soap.SOAPElement; 
import javax.xml.soap.SOAPEnvelope; 
import javax.xml.soap.SOAPException; 
import javax.xml.soap.SOAPFactory; 
import javax.xml.soap.SOAPHeader; 
import javax.xml.soap.SOAPMessage; 
import javax.xml.soap.SOAPPart; 
import javax.xml.transform.Source; 
 
 
// Constructing the SOAP Header 
 
SOAPHeader header = message.getSOAPHeader(); 
    if (header == null) 
  header = envelope.addHeader(); 
 
// Constructing the contents for performing Authorization 
 
   
String AUTH_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-
200401-wss-wssecurity-secext-1.0.xsd"; 
   
String AUTH_PREFIX = "wsse"; 
   
SOAPFactory soapFactory = SOAPFactory.newInstance(); 
   
SOAPElement wsSecHeaderElm = soapFactory.createElement("Security", 
   
 
 
AUTH_PREFIX, AUTH_NS); 
   
SOAPElement userNameTokenElm = soapFactory.createElement( 
   
 
 
"UsernameToken", AUTH_PREFIX, AUTH_NS); 
   
Name qname = envelope 
   
 
 
.createName( 
   
 
 
 
 
"Id", 
   
 
 
 
 
"wsu", 
   
 
 
 
 
"http://docs.oasis-
open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); 
   
userNameTokenElm.addAttribute(qname, "UsernameToken-27"); 
   
SOAPElement userNameElm = soapFactory.createElement("Username", 
   
 
 
AUTH_PREFIX, AUTH_NS); 
   
userNameElm.addTextNode(username); 
 
   
SOAPElement passwdElm = soapFactory.createElement("Password", 
   
 
 
AUTH_PREFIX, AUTH_NS); 
   
passwdElm.addTextNode(password); 
   
Name passwordType = envelope.createName("Type"); 
   
passwdElm 
   
 
 
.addAttribute( 
   
 
 
 
 
passwordType,