You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ro...@apache.org on 2004/08/02 15:53:32 UTC

cvs commit: ws-axis/c/tests/client/soapHeader/test9/rpc Makefile.am TestClient.cpp

roshan      2004/08/02 06:53:32

  Modified:    c/tests/client/soapHeader Makefile.am
  Added:       c/tests/client/soapHeader/test9 Makefile.am readme.txt
               c/tests/client/soapHeader/test9/rpc Makefile.am
                        TestClient.cpp
  Log:
  test case for testing adding attributes and namespaces for SOAP Headers
  
  Revision  Changes    Path
  1.3       +1 -1      ws-axis/c/tests/client/soapHeader/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/tests/client/soapHeader/Makefile.am,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Makefile.am	25 Jun 2004 06:29:54 -0000	1.2
  +++ Makefile.am	2 Aug 2004 13:53:32 -0000	1.3
  @@ -1 +1 @@
  -SUBDIRS = test1 test2 test3 test4 test6 test8
  +SUBDIRS = test1 test2 test3 test4 test6 test8 test9
  
  
  
  1.1                  ws-axis/c/tests/client/soapHeader/test9/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  SUBDIRS = rpc
  
  
  
  1.1                  ws-axis/c/tests/client/soapHeader/test9/readme.txt
  
  Index: readme.txt
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /**
   *   @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com)
   *
   */
  
  
  This client application can be used to test adding attributes to SOAP Headers.
  In the first part of the program it sets some soap headders with the Attributes. Then it calls echostring method.
  
  Steps to Run the Test
  =====================
  
  Linux
  =====
  1) Run the client and you can verify the result by looking at the TCP Monitor.  
  
  
  
  
  1.1                  ws-axis/c/tests/client/soapHeader/test9/rpc/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  bin_PROGRAMS = soapHeaderTest9RPC
  SUBDIRS =
  AM_CPPFLAGS = $(CPPFLAGS)
  soapHeaderTest9RPC_SOURCES = TestClient.cpp  ../../gen_src/rpc/InteropTestPortType.cpp ../../gen_src/rpc/SOAPStruct.cpp ../../gen_src/rpc/AxisClientException.cpp
  
  soapHeaderTest9RPC_LDADD   = @LINKCLIENTLIB@
  INCLUDES = -I$(AXISCPP_HOME)/include
  
  
  
  1.1                  ws-axis/c/tests/client/soapHeader/test9/rpc/TestClient.cpp
  
  Index: TestClient.cpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /*
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com)
   */
  
  #include <string>
  using namespace std;
  
  #include "../../gen_src/rpc/InteropTestPortType.h"
  #include <axis/server/IHeaderBlock.h>
  #include <axis/server/AxisException.h>
  
  #define ARRAYSIZE 2
  
  int
  main(int argc, char *argv[])
  {
      int x;
      char buffer1[100];
      char endpoint[256];
      const char *server = "localhost";
      const char *port = "80";
      if (argc == 3)
      {
  	server = argv[1];
  	port = argv[2];
      }
      printf("Usage :\n %s <server> <port>\n\n", argv[0]);
      //sprintf(endpoint, "http://%s:%s/axis/base", server, port);
      //endpoint for Axis CPP sample
      sprintf(endpoint, "http://%s:%s/axis/base", server, port);
      InteropTestPortType ws(endpoint, APTHTTP);
  
      /*create a header of the form:
         <SOAP-ENV:Header>
         <th:newName xmlns:th="http://ws.apache.org/axisCppTest/">
         <TestAuthHeader>
         <username>Test User</username>
         <password>Test Password</password>
         </TestAuthHeader>
         </th:newName>
         </SOAP-ENV:Header>
       */
  
      //set SOAP headers
      IHeaderBlock *phb = ws.createSOAPHeaderBlock("TestHeader", 
  		"http://ws.apache.org/axisCppTest/");
      phb->createNamespaceDecl("namesp1", "http://mynamespace.com");
  
      //create parent node
      BasicNode *parentNode = phb->createChild(ELEMENT_NODE);
      parentNode->setLocalName("Credentials");
      parentNode->createAttribute("type", "", "http://ws.apache.org/axisCppTest/", "normal");
      //create child node     
      BasicNode *childNode = phb->createChild(ELEMENT_NODE);
      childNode->setLocalName("username");
      childNode->createAttribute("usertype", "", "http://ws.apache.org/axisCppTest/", "normal_user");
      //create char node for value
      BasicNode *valueNode = phb->createChild(CHARACTER_NODE);
      valueNode->setValue("Test User");
      //buld node tree
      childNode->addChild(valueNode);
      parentNode->addChild(childNode);
  
      //add another node set
      childNode = phb->createChild(ELEMENT_NODE);
      childNode->setLocalName("password");
  
      valueNode = phb->createChild(CHARACTER_NODE);
      valueNode->setValue("Test Password");
  
      childNode->addChild(valueNode);
      parentNode->addChild(childNode);
  
      phb->addChild(parentNode);
  
      printf("Sending Requests to end point %s \n\n", endpoint);
      printf("invoking echoString...\n");
      //testing echoString 
      try 
      {
      if (0 == strcmp(ws.echoString("hello world"), "hello world"))
  	printf("successful\n");
      else
  	printf("failed\n");
      }
      catch (AxisException& e)
      {
          printf("%s\n", e.what());
      }
      catch(...)
      {
          printf("Unknown exception\n");
      }
  
      printf("Soap Header test end\n");
      return 0;
  }