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 ha...@apache.org on 2005/11/03 16:11:52 UTC
svn commit: r330560 - in
/webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest:
./ Calculator.hpp DynamicGetAnyObjectWithAttributesTest.cpp
Author: hawkeye
Date: Thu Nov 3 07:11:29 2005
New Revision: 330560
URL: http://svn.apache.org/viewcvs?rev=330560&view=rev
Log:
Created new unit test to check that we deserialise attributes correctly in getAnyObject
Added:
webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/
webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/Calculator.hpp
webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/DynamicGetAnyObjectWithAttributesTest.cpp
Added: webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/Calculator.hpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/Calculator.hpp?rev=330560&view=auto
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/Calculator.hpp (added)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/Calculator.hpp Thu Nov 3 07:11:29 2005
@@ -0,0 +1,49 @@
+// 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 is a manually edited version of the Generated stub code for CaluclatorDoc.wsdl
+ * to simplify the code to allow the cpp file to be edited to be used as a dynamic client
+ */
+#if !defined(__CALCULATOR_CLIENT_H__INCLUDED_)
+#define __CALCULATOR_CLIENT_H__INCLUDED_
+#include <axis/AxisException.hpp>
+#include <axis/client/Call.hpp>
+#include <iostream>
+#include <string>
+#include <exception>
+using namespace std;
+
+AXIS_CPP_NAMESPACE_USE
+
+class Calculator
+{
+public:
+ STORAGE_CLASS_INFO Calculator(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol=APTHTTP1_1);
+ STORAGE_CLASS_INFO Calculator();
+public:
+ STORAGE_CLASS_INFO virtual ~Calculator();
+public:
+ STORAGE_CLASS_INFO void SetSecure( char *, ...);
+ STORAGE_CLASS_INFO xsd__int div(xsd__int Value0,xsd__int Value1);
+
+private:
+ void includeSecure();
+ Call *m_pCall;
+
+protected:
+ std::string sArguments[8];
+};
+
+#endif /* !defined(__CALCULATOR_CLIENT_H__INCLUDED_)*/
Added: webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/DynamicGetAnyObjectWithAttributesTest.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/DynamicGetAnyObjectWithAttributesTest.cpp?rev=330560&view=auto
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/DynamicGetAnyObjectWithAttributesTest.cpp (added)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/dynamic/DynamicGetAnyObjectWithAttributesTest/DynamicGetAnyObjectWithAttributesTest.cpp Thu Nov 3 07:11:29 2005
@@ -0,0 +1,155 @@
+// 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 is a manually edited version of the Generated stub code for CaluclatorDoc.wsdl
+ * to simplify the code to allow the cpp file to be edited to be used as a dynamic client.
+ * This program uses getAnyObject() to get SOAP Fault
+ * This pogram has been hacked from the other dynamic tests becuase I wanted to make
+ * it obvious that it wasn't getting a calculator response back.
+ */
+
+#include "Calculator.hpp"
+#include <axis/AxisWrapperAPI.hpp>
+#include <axis/AxisUserAPI.hpp>
+#include <stdio.h>
+#include <axis/ISoapFault.hpp>
+
+
+
+Calculator::Calculator(const char* pcEndpointUri, AXIS_PROTOCOL_TYPE eProtocol)
+{
+ m_pCall=new Call();
+ m_pCall->setProtocol(eProtocol);
+ m_pCall->setEndpointURI(pcEndpointUri);
+
+}
+
+Calculator::Calculator()
+{
+ m_pCall=new Call();
+ m_pCall->setEndpointURI("http://localhost/axis/Calculator");
+}
+
+Calculator::~Calculator()
+{
+ delete m_pCall;
+ m_pCall=NULL;
+}
+
+
+void Calculator::SetSecure( char * pszArguments, ...)
+{
+ char ** ppszArgPtr = &pszArguments;
+ int iArgIndex = 0;
+
+ while( *ppszArgPtr != NULL)
+ {
+ sArguments[iArgIndex] = *ppszArgPtr;
+ iArgIndex++;
+ ppszArgPtr++;
+ }
+}
+
+xsd__int Calculator::div(xsd__int Value0, xsd__int Value1)
+{
+ xsd__int Ret = 0;
+ AnyType * any;
+ AnyType* pAny = new AnyType();
+ pAny->_size = 2;
+ pAny->_array = new char*[2];
+ char *p=new char[100];
+ sprintf(p,"<ns1:arg_0_3>%d</ns1:arg_0_3>",Value0);
+ pAny->_array[0]=strdup(p);
+ sprintf(p,"<ns1:arg_1_3>%d</ns1:arg_1_3>",Value1);
+ //pAny->_array[1]=strdup("<ns1:arg_1_3>0</ns1:arg_1_3>");
+ pAny->_array[1]=strdup(p);
+ const char* pcCmplxFaultName;
+ try
+ {
+ m_pCall->initialize(CPP_DOC_PROVIDER);
+ m_pCall->setTransportProperty(SOAPACTION_HEADER , "Calculator#div");
+ m_pCall->setSOAPVersion(SOAP_VER_1_1);
+ m_pCall->setOperation("div", "http://localhost/axis/Calculator");
+ includeSecure();
+ char cPrefixAndParamName0[17];
+ if (AXIS_SUCCESS == m_pCall->invoke())
+ {
+ // We know this has nothing to do with a calculator !
+ any = (AnyType*)m_pCall->getAnyObject();
+ if(any!=NULL)
+ {
+ cout << any->_array[0]<<endl;
+ }
+ }
+
+ }
+ catch(AxisException& e)
+ {
+ cout << "axis exception "<<e.what()<<endl;
+ any = (AnyType*)m_pCall->getAnyObject();
+ if(any!=NULL)
+ {
+ cout << any->_size<<endl;
+ cout << any->_array[0]<<endl;
+ }
+ //throw;
+ }
+ m_pCall->unInitialize();
+ delete pAny;
+ delete p;
+ return Ret;
+
+}
+
+
+
+void Calculator::includeSecure()
+{
+ m_pCall->setTransportProperty( SECURE_PROPERTIES, (const char *) &sArguments);
+}
+
+int main(int argc, char* argv[])
+{
+ char endpoint[256];
+ const char* url="http://localhost:9080/Calculator/services/Calculator";
+ int iResult;
+ if(argc > 1){
+ url=argv[1];
+ }
+ try
+ {
+ sprintf(endpoint, "%s", url);
+ Calculator ws(endpoint);
+ ws.div(10,0);
+ }
+ catch(AxisException& e)
+ {
+ cout << "Exception : " << e.what() << endl;
+ }
+ catch(exception& e)
+ {
+ cout << "Unknown exception has occured" << endl;
+ }
+ catch(...)
+ {
+ cout << "Unspecified exception has occured" << endl;
+ }
+ cout << "----------------------------TEST COMPLETE------------------------------------" << endl;
+ return 0;
+}
+
+
+
+