예제 #1
0
		/** Exposes the PRONOM web service.  This is the only method required to call a
		 * web service.  The URL of the web service must be provided.  The web server
		 * name or IP address is then extracted from the URL.
		 * @param theWebServiceURL  Full URL to webservice
		 * @param theMethodName     Name of the web service method.  The suffix "request"
		 * is appended for the SOAP request and the suffix "response" is appended for the
		 * SOAP response.
		 * @param theXMLWrapper     Name of XML Element which wraps the result inside the web service response
		 */
		public static String sendRequest(string theWebServiceURL, string theProxyHost, int theProxyPort, string theMethodName, string theXMLWrapper) //throws Exception{		
		{
			//assume that the communication fails.  If it succeeds, the flag will be reset at the end
			isCommSuccess = false;
		    
			String theResult = "";
		    
			//set up the URL
			//URL myUrl = null;
			Uri myUrl = null;
			try {
				myUrl = new Uri(theWebServiceURL); //URL(theWebServiceURL);
			}
			catch (Exception e) //MalformedURLException e)
			{
				throw new //WSException("Invalid URL for PRONOM web services" + theWebServiceURL +"\n"+e.getMessage());
				AlexandriaException("Invalid URL for PRONOM web services" + theWebServiceURL + "\n" + e.Message);
			}
		    
		    
			try {
				// Create and send a message
				System.Web.Services.Description.Message aMessage = new System.Web.Services.Description.Message();
		        
				//If a proxy server is required for connecting to web service, then record its settings
				try {
					if(theProxyHost.Length > 0 && theProxyPort > 0)
					{
						//TODO: figure out how to port this
						/*
						org.apache.soap.transport.http.SOAPHTTPConnection aSOAPConnection = new org.apache.soap.transport.http.SOAPHTTPConnection();
						aSOAPConnection.setProxyHost(theProxyHost);
						aSOAPConnection.setProxyPort(theProxyPort);
						aMessage.setSOAPTransport(aSOAPConnection);
						*/
					}
				}
				catch (Exception e)
				{
					throw new //WSException("Error while creating the proxy settings" +"\n"+e.getMessage());
					AlexandriaException("Error while creating the proxy settings" + "\n" + e.Message);
				}
		        
				//send the SOAP message to webservice
		        
				//TODO: figure out how to port this
				/*
				aMessage.send(myUrl, theWebServiceURL, createEnvelope(theMethodName));            
		        
				//Receive the message response
				org.apache.soap.transport.SOAPTransport st = aMessage.getSOAPTransport();
				BufferedReader br = st.receive( );
				String line = br.readLine( );
				if(line == null) {
				} else {
					while (line != null) {
						theResult += line;
						line = br.readLine( );
					}
				}
				*/
			}
			catch (Exception e)
			{
				throw new //WSException("Error while sending message to PRONOM web services" +"\n"+e.getMessage());
				AlexandriaException("Error while sending message to PRONOM web services" +"\n"+e.Message);
			}
		    
		    
			// theResult now contains the complete result from the
			// webservice in XML format.
			try
			{
				theResult = PronomWebService.extractXMLelement(theResult, theMethodName + "Response");
			}
			catch(Exception)
			{
				throw new AlexandriaException("Unexpected response from PRONOM web service");
			}
		    
			try
			{
				theResult = PronomWebService.extractXMLelement(theResult, theXMLWrapper);
			}
			catch(Exception)
			{
				throw new AlexandriaException("Response from PRONOM web service did not contain the expected element");
			}
		    
			//indicate that the communication was successful
			isCommSuccess = true;
		    
			return theResult;
		}
예제 #2
0
        /** Exposes the PRONOM web service.  This is the only method required to call a
         * web service.  The URL of the web service must be provided.  The web server
         * name or IP address is then extracted from the URL.
         * @param theWebServiceURL  Full URL to webservice
         * @param theMethodName     Name of the web service method.  The suffix "request"
         * is appended for the SOAP request and the suffix "response" is appended for the
         * SOAP response.
         * @param theXMLWrapper     Name of XML Element which wraps the result inside the web service response
         */
        public static String sendRequest(string theWebServiceURL, string theProxyHost, int theProxyPort, string theMethodName, string theXMLWrapper)         //throws Exception{
        {
            //assume that the communication fails.  If it succeeds, the flag will be reset at the end
            isCommSuccess = false;

            String theResult = "";

            //set up the URL
            //URL myUrl = null;
            Uri myUrl = null;

            try {
                myUrl = new Uri(theWebServiceURL); //URL(theWebServiceURL);
            }
            catch (Exception e)                    //MalformedURLException e)
            {
                throw new                          //WSException("Invalid URL for PRONOM web services" + theWebServiceURL +"\n"+e.getMessage());
                      AlexandriaException("Invalid URL for PRONOM web services" + theWebServiceURL + "\n" + e.Message);
            }


            try {
                // Create and send a message
                System.Web.Services.Description.Message aMessage = new System.Web.Services.Description.Message();

                //If a proxy server is required for connecting to web service, then record its settings
                try {
                    if (theProxyHost.Length > 0 && theProxyPort > 0)
                    {
                        //TODO: figure out how to port this

                        /*
                         * org.apache.soap.transport.http.SOAPHTTPConnection aSOAPConnection = new org.apache.soap.transport.http.SOAPHTTPConnection();
                         * aSOAPConnection.setProxyHost(theProxyHost);
                         * aSOAPConnection.setProxyPort(theProxyPort);
                         * aMessage.setSOAPTransport(aSOAPConnection);
                         */
                    }
                }
                catch (Exception e)
                {
                    throw new                     //WSException("Error while creating the proxy settings" +"\n"+e.getMessage());
                          AlexandriaException("Error while creating the proxy settings" + "\n" + e.Message);
                }

                //send the SOAP message to webservice

                //TODO: figure out how to port this

                /*
                 * aMessage.send(myUrl, theWebServiceURL, createEnvelope(theMethodName));
                 *
                 * //Receive the message response
                 * org.apache.soap.transport.SOAPTransport st = aMessage.getSOAPTransport();
                 * BufferedReader br = st.receive( );
                 * String line = br.readLine( );
                 * if(line == null) {
                 * } else {
                 *      while (line != null) {
                 *              theResult += line;
                 *              line = br.readLine( );
                 *      }
                 * }
                 */
            }
            catch (Exception e)
            {
                throw new                 //WSException("Error while sending message to PRONOM web services" +"\n"+e.getMessage());
                      AlexandriaException("Error while sending message to PRONOM web services" + "\n" + e.Message);
            }


            // theResult now contains the complete result from the
            // webservice in XML format.
            try
            {
                theResult = PronomWebService.extractXMLelement(theResult, theMethodName + "Response");
            }
            catch (Exception)
            {
                throw new AlexandriaException("Unexpected response from PRONOM web service");
            }

            try
            {
                theResult = PronomWebService.extractXMLelement(theResult, theXMLWrapper);
            }
            catch (Exception)
            {
                throw new AlexandriaException("Response from PRONOM web service did not contain the expected element");
            }

            //indicate that the communication was successful
            isCommSuccess = true;

            return(theResult);
        }
		public System.Web.Services.Description.Message ReadObject_Message (bool isNullable, bool checkType)
		{
			System.Web.Services.Description.Message ob = null;
			if (isNullable && ReadNull()) return null;

			if (checkType) 
			{
				System.Xml.XmlQualifiedName t = GetXsiType();
				if (t != null) 
				{
					if (t.Name != "Message" || t.Namespace != "http://schemas.xmlsoap.org/wsdl/")
						throw CreateUnknownTypeException(t);
				}
			}

			ob = new System.Web.Services.Description.Message ();

			Reader.MoveToElement();

			while (Reader.MoveToNextAttribute())
			{
				if (Reader.LocalName == "name" && Reader.NamespaceURI == "") {
					ob.Name = XmlConvert.DecodeName(Reader.Value);
				}
				else if (IsXmlnsAttribute (Reader.Name)) {
				}
				else {
					UnknownNode (ob);
				}
			}

			Reader.MoveToElement();
			if (Reader.IsEmptyElement) {
				Reader.Skip ();
				return ob;
			}

			Reader.ReadStartElement();
			Reader.MoveToContent();

			bool b26=false, b27=false;

			System.Web.Services.Description.MessagePartCollection o29 = ob.Parts;
			int n28=0;

			while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
			{
				if (Reader.NodeType == System.Xml.XmlNodeType.Element) 
				{
					if (Reader.LocalName == "documentation" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/" && !b27) {
						b27 = true;
						ob.Documentation = Reader.ReadElementString ();
					}
					else if (Reader.LocalName == "part" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/" && !b26) {
						if (o29 == null)
							throw CreateReadOnlyCollectionException ("System.Web.Services.Description.MessagePartCollection");
						o29.Add (ReadObject_MessagePart (false, true));
						n28++;
					}
					else {
						UnknownNode (ob);
					}
				}
				else
					UnknownNode(ob);

				Reader.MoveToContent();
			}


			ReadEndElement();

			return ob;
		}
 internal void SetParent(System.Web.Services.Description.Message parent)
 {
     this.parent = parent;
 }
예제 #5
0
 internal void SetParent(System.Web.Services.Description.Message parent)
 {
     this.parent = parent;
 }