Show TOC Start of Content Area

Syntax documentation Client Application Coding Example

// Establish the URL endpoint which is the connector Web service.

   
to = reqBase + "/irj/servlet/prt/soap/ConnectorWebService";
   URLEndpoint urlEndpoint = 
new URLEndpoint(to);
   
int id = Integer.parseInt(id_msg);

// Construct the SOAP message.
   
SOAPMessage msg = constructMessage(id);

// Send the message to the provider using the connection.
   
SOAPMessage reply = con.call(msg, urlEndpoint);

// Constructing the headers of the SOAP message. 
// (according to your requirements).
// A common header declaration, as shown here, is defining namespaces.
// Create a message factory.
   
MessageFactory mf = MessageFactory.newInstance();

// Create a message from the message factory.
   
SOAPMessage msg = mf.createMessage();

// Message creation takes care of creating the SOAPPart,
// a required part of the message as per the SOAP 1.1 specification.
   
SOAPPart sp = msg.getSOAPPart();

// Retrieve the envelope from the soap part to start building the 
// soap message.
   
SOAPEnvelope envelope = sp.getEnvelope();

// Create a soap header from the envelope.
   
SOAPHeader hdr = envelope.getHeader();

// get a soap body from the envelope.
   
SOAPBody bdy = envelope.getBody();

   bdy.setEncodingStyle(
"http://schemas.xmlsoap.org/soap/encoding/");
   bdy.addNamespaceDeclaration(
"wn0", wn0URI);
   bdy.addNamespaceDeclaration(
"wn1""http://www.w3.org/2001/XMLSchema");
   bdy.addNamespaceDeclaration(
"wn2",
                               
"http://www.w3.org/2000/10/XMLSchema");
   bdy.addNamespaceDeclaration(
"wn3""http://www.w3.org/1999/XMLSchema");
   bdy.addNamespaceDeclaration(
"prt""http://prt.java.soap/schemas");
   bdy.addNamespaceDeclaration(
"wn4",
                               
"urn:com.sap.ConnectorWebService");
   bdy.addNamespaceDeclaration(
"xsi", xsiURI);

// You generate the rest of the SOAP message according to the method
// you want the Web server to run. (Note: Only one method per request.)
// For example: getting connector capabilities.
   
Name childName = null;

// Create a Name object for the method.
   
Name methodName = envelope.createName("getCapabilities""wn4"null);

// Add a soap body element to the soap body.
   
SOAPBodyElement service = bdy.addBodyElement(methodName);

   childName = envelope.createName(
"JNDIName");
   SOAPElement param0   = service.addChildElement(childName);
   Name typeName = envelope.createName(
"type""xsi", xsiURI);
   param0.addAttribute(typeName, 
"wn1:string");
   param0.addTextNode(
"EISConnections/JDBCFactory");

   childName = envelope.createName(
"connectionString");

   SOAPElement param1 = service.addChildElement(childName);
   typeName = envelope.createName(
"type""xsi", xsiURI);
   param1.addAttribute(typeName, 
"wn1:string");
   param1.addTextNode(
"driver=com.sap.jdbc.sqlserver.SQLServerDriver,
                       url=jdbc:sap:sqlserver://localhost:1433;
                       user=sa;password=sa;databaseName=Northwind,"
);

// Example for launching a query:
   
private void executeQuery(SOAPEnvelope envelope, SOAPBody bdy) 
                 
throws Exception
   {
    Name childName  = 
null;
    Name methodName = envelope.createName(
"executeQuery""wn4"null);

// Add a soap body element to the soap body.
    
SOAPBodyElement service = bdy.addBodyElement(methodName);

    childName = envelope.createName(
"JNDIName");
    SOAPElement param0 = service.addChildElement(childName);
    Name typeName = envelope.createName(
"type","xsi",xsiURI);
    param0.addAttribute(typeName,
"wn1:string");
    param0.addTextNode(
"EISConnections/JDBCFactory");

    childName = envelope.createName(
"connectionString");
    SOAPElement param1 = service.addChildElement(childName);
    typeName = envelope.createName(
"type","xsi",xsiURI);
    param1.addAttribute(typeName,
"wn1:string");

    
param1.addTextNode("driver=com.sap.jdbc.sqlserver.SQLServerDriver,
                       url=jdbc:sap:sqlserver://localhost:1433;
                       user=sa;password=sa;databaseName=Northwind,"
);

    childName = envelope.createName("queryString");
    SOAPElement param2 = service.addChildElement(childName);
    typeName = envelope.createName(
"type","xsi",xsiURI);
    param2.addAttribute(typeName,
"wn1:string");
    param2.addTextNode(
"select * from  [dbo].[Customers]");

    childName = envelope.createName(
"startFromRecord");
    SOAPElement param3 = service.addChildElement(childName);
    typeName = envelope.createName(
"type","xsi",xsiURI);
    param3.addAttribute(typeName,
"wn1:int");
    param3.addTextNode(
"1");

    childName = envelope.createName(
"recordsNumberToRetrive");
    SOAPElement param4 = service.addChildElement(childName);
    typeName = envelope.createName(
"type","xsi",xsiURI);
    param4.addAttribute(typeName,
"wn1:int");
    param4.addTextNode(
"10");
   }

 

End of Content Area