⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bookorderproxy.java

📁 java web services how to program
💻 JAVA
字号:
// BookOrderProxy.java
// BookOrderProxy is a service proxy for Bookstores
// Book Order Web service. 
package jws1casestudy.pricefinder;

// Java core packages
import java.net.URL;

// Java XML packages
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;

// Axis packages
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;

// Deitel packages
import jws1casestudy.pricefinder.common.*;

public class BookOrderProxy
{
   // invocation instance for Web service
   private Call call;
   
   // construct BookOrderProxy
   public BookOrderProxy( URL wsdlURL, 
      QName serviceIdentifier, QName customerNamespace,
      String portName ) throws ServiceException
   {
      // construct service object based on WSDL
      Service service = 
         new Service( wsdlURL, serviceIdentifier );

      // create method identifier
      QName methodIdentifier = new QName( null, portName );
         
      // create Call that specifies service port and
      // method to call
      call = ( Call )service.createCall(
         methodIdentifier , "placeOrder" );
      
      // create serializer factory
      BeanSerializerFactory serializerFactory =
         new BeanSerializerFactory( Customer.class, 
            customerNamespace );
      
      // create deserializer factory
      BeanDeserializerFactory deserializerFactory =
         new BeanDeserializerFactory( Customer.class, 
            customerNamespace );
      
      // register type mapping for Customer serializer
      // and deserializer
      call.registerTypeMapping( Customer.class, 
         customerNamespace, serializerFactory, 
         deserializerFactory );        
      
   } // end constructor
   
   // order book from book store
   public void placeOrder( String isbn, Customer customer )
   {

      // create DII call to order book 
      try {

         // invoke Web service 
         call.invoke( new Object[] { isbn, customer } );

      } // end try

      // handle exception in accessing Web service
      catch( Exception exception ) {
         exception.printStackTrace();
      }

   } // end method orderBook
   
} // end class BookOrderProxy

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -