You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by wh...@apache.org on 2005/06/21 16:14:14 UTC

cvs commit: ws-axis/c/tests/auto_build/testcases/wsdls Attachment1.wsdl

whitlock    2005/06/21 07:14:14

  Modified:    c/include/axis/client Stub.hpp
               c/src/engine/client Stub.cpp
               c/src/wsdl/org/apache/axis/wsdl/wsdl2ws
                        WrapperConstants.java
               c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal
                        ClientStubHeaderWriter.java ClientStubWriter.java
               c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info Type.java
                        TypeMap.java
  Added:       c/tests/auto_build/testcases/client/cpp
                        Attachment1Client.cpp
               c/tests/auto_build/testcases/output Attachment1.expected
                        Attachment1_ServerResponse.expected
               c/tests/auto_build/testcases/tests Attachment1.xml
               c/tests/auto_build/testcases/wsdls Attachment1.wsdl
  Log:
  Attachments: add in support in WSDL2Ws for referenced attachments and add in the Attachment1 unit test.
  This also adds in Stub::createAttachment.
  
  Revision  Changes    Path
  1.24      +7 -0      ws-axis/c/include/axis/client/Stub.hpp
  
  Index: Stub.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/include/axis/client/Stub.hpp,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Stub.hpp	20 Jun 2005 10:14:13 -0000	1.23
  +++ Stub.hpp	21 Jun 2005 14:14:13 -0000	1.24
  @@ -610,6 +610,13 @@
       */
       Call *getCall() { return m_pCall; }
   
  +	/**
  +	 * Creates an ISoapAttachment which represents an attachment. The ISoapAttachment should be passed as 
  +	 * an attachmment parameter to a web service. The storage associated with the ISoapAttachment will be 
  +	 * automatically deleted by Axis C++ if it is passed as a parameter to a web service.
  +	 */
  +	ISoapAttachment* createSoapAttachment();
  +
     protected:
     /**
       * Apply user set preferences to each call made on the Stub object.
  
  
  
  1.48      +7 -0      ws-axis/c/src/engine/client/Stub.cpp
  
  Index: Stub.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/engine/client/Stub.cpp,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- Stub.cpp	17 Jun 2005 15:37:28 -0000	1.47
  +++ Stub.cpp	21 Jun 2005 14:14:13 -0000	1.48
  @@ -443,3 +443,10 @@
       delete[]cpUsernamePassword;
       delete[]base64Value;
   }
  +
  +ISoapAttachment* Stub::createSoapAttachment()
  +{
  +	return m_pCall->createSoapAttachment();
  +}
  +
  +
  
  
  
  1.15      +1 -0      ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WrapperConstants.java
  
  Index: WrapperConstants.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WrapperConstants.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- WrapperConstants.java	10 Feb 2005 18:14:15 -0000	1.14
  +++ WrapperConstants.java	21 Jun 2005 14:14:13 -0000	1.15
  @@ -24,6 +24,7 @@
       public static final String DEFAULT_SIMPLETYPE_PACKAGE = "lk.opensource.axis2.wrappers.simpleType.";
       public static final String SCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema";
   	public static final String SOAPENC_NAMESPACE = "http://schemas.xmlsoap.org/soap/encoding/";
  +	public static final String APACHE_XMLSOAP_NAMESPACE = "http://xml.apache.org/xml-soap";
       //wsdl constants
       public static final String ELEMENT_COMPLEX_TYPE = "ComplexType";
       public static final String ELEMENT_SEQUENCE = "sequence";
  
  
  
  1.36      +11 -33    ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubHeaderWriter.java
  
  Index: ClientStubHeaderWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubHeaderWriter.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- ClientStubHeaderWriter.java	13 Jun 2005 13:48:56 -0000	1.35
  +++ ClientStubHeaderWriter.java	21 Jun 2005 14:14:13 -0000	1.36
  @@ -109,51 +109,28 @@
                   //write parameter names 
                   boolean hasInputParms = false;
                   Iterator params = minfo.getInputParameterTypes().iterator();
  -                if (params.hasNext())
  +                for (int j = 0; params.hasNext(); j++)
                   {
  +                    if (j>0) writer.write(", ");
                       hasInputParms = true;
  -                    ParameterInfo fparam = (ParameterInfo) params.next();
  -                    String paramTypeName = WrapperUtils.getClassNameFromParamInfoConsideringArrays(fparam, wscontext);
  -                    if (CUtils.isSimpleType(paramTypeName)
  -							&& fparam.isNillable()
  -							&& !(CUtils.isPointerType(paramTypeName)))
  -                    {
  -                    	writer.write(
  -    	                        paramTypeName
  -    	                            + " * Value"
  -    	                            + 0);
  -                    }
  -                    else
  -                    {
  -	                    writer.write(
  -	                        paramTypeName
  -	                            + " Value"
  -	                            + 0);
  -                    }
  -                }
  -                for (int j = 1; params.hasNext(); j++)
  -                {
                       ParameterInfo nparam = (ParameterInfo) params.next();
                       String paramTypeName = WrapperUtils.getClassNameFromParamInfoConsideringArrays(nparam, wscontext);
  -                    if (CUtils.isSimpleType(paramTypeName)
  +                    if (nparam.getType().isAttachment())
  +                    {
  +                    	writer.write("ISoapAttachment *Value" + j);
  +                    }
  +                    else if (CUtils.isSimpleType(paramTypeName)
   							&& nparam.isNillable()
   							&& !(CUtils.isPointerType(paramTypeName)))
                       {
  -                    	writer.write(", "
  -                    			+ paramTypeName
  -    	                        + " * Value"
  -    	                        + j);
  +                    	writer.write(paramTypeName + " * Value" + j);
                       }
                       else
                       {
  -	                    writer.write(", "
  -	                    		+ paramTypeName
  -	                            + " Value"
  -	                            + j);
  +	                    writer.write(paramTypeName + " Value" + j);
                       }
  -                    
  -                    
                   }
  +
                   if (isAllTreatedAsOutParams)
                   {
                       params = minfo.getOutputParameterTypes().iterator();
  @@ -196,6 +173,7 @@
           {
               writer.write("#include <axis/client/Stub.hpp>\n");
               writer.write("#include <axis/OtherFaultException.hpp>\n");
  +            writer.write("#include <axis/ISoapAttachment.hpp>\n");
               writer.write("#include <axis/ISoapFault.hpp>\n");
               writer.write("AXIS_CPP_NAMESPACE_USE\n");
               Type atype;
  
  
  
  1.92      +15 -3     ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
  
  Index: ClientStubWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- ClientStubWriter.java	14 Jun 2005 13:03:05 -0000	1.91
  +++ ClientStubWriter.java	21 Jun 2005 14:14:13 -0000	1.92
  @@ -312,7 +312,11 @@
   		typeisarray = false;
   	    }
   	    typeissimple = CUtils.isSimpleType (paraTypeName);
  -	    if (typeisarray
  +          if (paramtype.getType().isAttachment())
  +          {
  +         	writer.write("ISoapAttachment *Value0");
  +          }
  +          else if (typeisarray
   		|| (typeissimple
   		    && (!((ParameterInfo) paramsB.get (0)).isNillable ()
   			|| CUtils.isPointerType(paraTypeName))))
  @@ -366,7 +370,11 @@
   		    typeisarray = false;
   		}
   		typeissimple = CUtils.isSimpleType (paraTypeName);
  -		if (typeisarray
  +            if (paramtype.getType().isAttachment())
  +            {
  +           	    writer.write(", ISoapAttachment *Value" + i);
  +            }
  +            else if (typeisarray
   		    || (typeissimple
   			&& (!((ParameterInfo) paramsB.get (i)).isNillable ()
   			    || CUtils.isPointerType(paraTypeName))))
  @@ -618,7 +626,11 @@
   				      namespace + "\"));\n");
   		    }
   
  -		    if (typeisarray)
  +		    if (param.getType().isAttachment())
  +		    {
  +			writer.write ("\tm_pCall->addAttachmentParameter(Value" + i + ", cPrefixAndParamName" + i);
  +		    }
  +		    else if (typeisarray)
   		    {
   			// Array
   			Type arrayType = WrapperUtils.getArrayType (type);
  
  
  
  1.26      +20 -0     ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java
  
  Index: Type.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Type.java	23 Mar 2005 15:45:05 -0000	1.25
  +++ Type.java	21 Jun 2005 14:14:14 -0000	1.26
  @@ -91,6 +91,9 @@
       /* is this type going to be thrown as a soap fault? */
       private boolean isFault = false;
   
  +    /* Is this type an attachment under the http://xml.apache.org/xml-soap namespace? */
  +    private boolean isAttachment = false;
  +
       public Type(
           QName name,
           String languageSpecificName,
  @@ -171,6 +174,18 @@
               }
           }
           this.attribOrder = new Vector();
  +
  +        if (name.getNamespaceURI().equals(WrapperConstants.APACHE_XMLSOAP_NAMESPACE) && 
  +            (name.getLocalPart().equals("DataHandler") ||
  +             name.getLocalPart().equals("Image") ||
  +             name.getLocalPart().equals("MimeMultipart") ||
  +             name.getLocalPart().equals("Source") ||
  +             name.getLocalPart().equals("octet-stream") ||
  +             name.getLocalPart().equals("DataHandler") ||
  +             name.getLocalPart().equals("PlainText")) )
  +        {
  +             isAttachment = true;
  +        }
       }
   
       /**
  @@ -582,4 +597,9 @@
       {
       	return isFault;
       }
  +
  +    public boolean isAttachment() 
  +    {
  +    	return isAttachment;
  +    }
   }
  
  
  
  1.20      +12 -0     ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/TypeMap.java
  
  Index: TypeMap.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/TypeMap.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- TypeMap.java	3 Jun 2005 08:55:39 -0000	1.19
  +++ TypeMap.java	21 Jun 2005 14:14:14 -0000	1.20
  @@ -105,6 +105,12 @@
           basicTypeClass2QNamemap.put("xsd__anyURI",				new QName(WrapperConstants.SCHEMA_NAMESPACE, "anyURI"));
           basicTypeClass2QNamemap.put("xsd__QName",				new QName(WrapperConstants.SCHEMA_NAMESPACE, "QName"));
           basicTypeClass2QNamemap.put("xsd__notation",			new QName(WrapperConstants.SCHEMA_NAMESPACE, "NOTATION"));
  +        basicTypeClass2QNamemap.put("ISoapAttachment",		new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "Image"));
  +        basicTypeClass2QNamemap.put("ISoapAttachment",		new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "PlainText"));
  +        basicTypeClass2QNamemap.put("ISoapAttachment",		new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "Multipart"));
  +        basicTypeClass2QNamemap.put("ISoapAttachment",		new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "Source"));
  +        basicTypeClass2QNamemap.put("ISoapAttachment",		new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "octet-stream"));
  +        basicTypeClass2QNamemap.put("ISoapAttachment",		new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "DataHandler"));
   
   
           // xml -> c type mapping 
  @@ -152,6 +158,12 @@
           basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "anyURI"),				"xsd__anyURI");
           basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "QName"),				"xsd__QName");
           basicTypeQname2classmap.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "NOTATION"),			"xsd__notation");
  +        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "Image"),		"ISoapAttachment");
  +        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "PlainText"),	"ISoapAttachment");
  +        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "Multipart"),	"ISoapAttachment");
  +        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "Source"),		"ISoapAttachment");
  +        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "octet-stream"),	"ISoapAttachment");
  +        basicTypeQname2classmap.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE, "DataHandler"),	"ISoapAttachment");
   
           /* TODO:
            *   Should be removed when the following issue will be fixed :
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/client/cpp/Attachment1Client.cpp
  
  Index: Attachment1Client.cpp
  ===================================================================
  // Copyright 2003-2004 The Apache Software Foundation.
  // (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
  // 
  // 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.
  
  #include "AttachmentBindingImpl.hpp"
  #include <axis/AxisException.hpp>
  #include <ctype.h>
  #include <iostream>
  
  int main(int argc, char* argv[])
  {
  	bool bSuccess = false;
  	int	iRetryIterationCount = 3;
  
  	do
  	{
  		try
  		{
  			AttachmentBindingImpl ws(argv[1]);
  			ISoapAttachment *att = ws.createSoapAttachment();
  			att->addHeader(AXIS_CONTENT_TYPE,"text/plain");
  			att->addHeader(AXIS_CONTENT_TRANSFER_ENCODING,"base64");
  			
  			char *text="Some attachment text";
  			xsd__base64Binary b64b1;
  			b64b1.__ptr = (xsd__unsignedByte*)text;
  			b64b1.__size = strlen(text)+1;
  			att->addBody(&b64b1);	
  
  			xsd__int iResult = ws.put(att);
  			cout << iResult << endl;
  			bSuccess = true;
  		}
  		catch(AxisException& e)
  		{
  			bool bSilent = false;
  			if( e.getExceptionCode() == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
  			{
  				if( iRetryIterationCount > 0)
  				{
  					bSilent = true;
  				}
  			}
  			else
  			{
  				iRetryIterationCount = 0;
  			}		
  
  			if( !bSilent)
  			{
  				cout << "Exception : " << e.what() << endl;
  			}
  		}
  		catch(exception& e)
  		{
  		    cout << "Unknown exception has occured" << endl;
  		}
  		catch(...)
  		{
  		    cout << "Unknown exception has occured" << endl;
  		}
  		iRetryIterationCount--;
  	} while( iRetryIterationCount > 0 && !bSuccess);
  
  	cout<< "---------------------- TEST COMPLETE -----------------------------"<< endl;
  	return 0;
  }
  
  void PrintUsage()
  {
  	printf("Usage :\n Calculator <url>\n\n");
  	exit(1);
  }
  
  bool IsNumber(const char* p)
  {
  	for (int x=0; x < strlen(p); x++)
  	{
  		if (!isdigit(p[x])) return false;
  	}
  	return true;
  }
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/output/Attachment1.expected
  
  Index: Attachment1.expected
  ===================================================================
  5
  ---------------------- TEST COMPLETE -----------------------------
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/output/Attachment1_ServerResponse.expected
  
  Index: Attachment1_ServerResponse.expected
  ===================================================================
  HTTP/1.1 200 OK
  Server: WebSphere Application Server/5.1
  Content-Type: text/xml; charset=utf-8
  Content-Language: en-GB
  Transfer-Encoding: chunked
  
  ###
  <?xml version="1.0" encoding="utf-8"?>
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header/>
  <soapenv:Body>
  <putResponse xmlns="http://localhost/axis/Attachment1">
  <putReturn>5</putReturn>
  </putResponse>
  </soapenv:Body>
  </soapenv:Envelope>
  0
  
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/tests/Attachment1.xml
  
  Index: Attachment1.xml
  ===================================================================
  <test>
      <name>Attachment1</name>
      <description>Attachment1</description>
      <clientLang>cpp</clientLang>
      <clientCode>Attachment1Client.cpp</clientCode>
      <wsdl>Attachment1.wsdl</wsdl>
      <expected>
          <output>
              Attachment1.expected
          </output>
          <serverResponse>
  		Attachment1_ServerResponse.expected
          </serverResponse>
      </expected>
      <endpoint>http://localhost:80/axis/Attachment1</endpoint>
  </test>
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/wsdls/Attachment1.wsdl
  
  Index: Attachment1.wsdl
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <wsdl:definitions targetNamespace="http://attachment1" 
  	xmlns:impl="http://attachment1" 
  	xmlns:intf="http://attachment1" 
  	xmlns:tns2="http://xml.apache.org/xml-soap" 
  	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
  	xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
  	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  
   <wsdl:types>
    <schema elementFormDefault="qualified" 
  	targetNamespace="http://attachment1" 
  	xmlns="http://www.w3.org/2001/XMLSchema" 
  	xmlns:impl="http://attachment1" 
  	xmlns:intf="http://attachment1" 
  	xmlns:tns2="http://xml.apache.org/xml-soap" 
  	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
  	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <import namespace="http://xml.apache.org/xml-soap"/>
     <element name="put">
      <complexType>
       <sequence>
        <element name="arg_0_0" type="tns2:DataHandler"/>
       </sequence>
      </complexType>
     </element>
     <element name="putResponse">
      <complexType>
       <sequence>
        <element name="putReturn" type="xsd:int"/>
       </sequence>
      </complexType>
     </element>
    </schema>
   </wsdl:types>
  
     <wsdl:message name="putRequest">
        <wsdl:part element="impl:put" name="parameters"/>
     </wsdl:message>
     <wsdl:message name="putResponse">
        <wsdl:part element="impl:putResponse" name="parameters"/>
     </wsdl:message>
  
     <wsdl:portType name="AttachmentBindingImpl">
        <wsdl:operation name="put">
           <wsdl:input message="impl:putRequest" name="putRequest"/>
           <wsdl:output message="impl:putResponse" name="putResponse"/>
        </wsdl:operation>
     </wsdl:portType>
  
     <wsdl:binding name="Attachment1SoapBinding" type="impl:AttachmentBindingImpl">
        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="put">
           <wsdlsoap:operation soapAction=""/>
           <wsdl:input name="putRequest">
              <wsdlsoap:body use="literal"/>
           </wsdl:input>
           <wsdl:output name="putResponse">
              <wsdlsoap:body use="literal"/>
           </wsdl:output>
        </wsdl:operation>
     </wsdl:binding>
  
     <wsdl:service name="AttachmentBindingImplService">
        <wsdl:port binding="impl:Attachment1SoapBinding" name="Attachment1">
           <wsdlsoap:address location="http://localhost:9080/Attachment1/services/Attachment1"/>
        </wsdl:port>
     </wsdl:service>
  </wsdl:definitions>