简体   繁体   English

消费SOA Suite WSDL SOAP

[英]Consuming SOA Suite WSDL SOAP

here is what I got: installed and configured SOA Suite 11g, (weblogic server 10.3, repository creation utility, soa suite, jdeveloper studio, Oracle XE database 10g). 我得到的是:安装并配置了SOA Suite 11g(weblogic服务器10.3,存储库创建实用程序,soa套件,jdeveloper studio,Oracle XE数据库10g)。

SOA infrastructure Service engines (BPEL, Mediator, Business rules, Himan workflow Metadastore (MDS) Enterprise manager, web service manager, B2B, Adapterframework (JCA) Oracle Business Activity monitoring (BAM) SOA基础结构服务引擎(BPEL,介体,业务规则,Himan工作流Metadastore(MDS)企业管理器,Web服务管理器,B2B,适配器框架(JCA)Oracle业务活动监视(BAM)

All set up and running. 全部设置并运行。 tutorial project Purchase Order Processing set up and running as well (its' from book "Getting started with Oracle SOA suite 11g R1 A hands on tutorial"). 教程项目“采购订单处理”也已设置并运行(它来自《 Oracle SOA套件11g R1入门教程》一书)。

Tests are executing fine, all passed (several types of credit cards, small, medium and large orders, automatic and manual approval, several types on shipping automatically chosen on size of order etc.) 测试执行良好,全部通过(几种类型的信用卡,小型,中型和大型订单,自动和手动批准,根据订单大小自动选择的几种运输方式等)

在此处输入图片说明

What I want now is to connect - consume - that service from palin JAVA application. 我现在想要的是从Palin JAVA应用程序连接-使用该服务。 Following this tutorial ( http://theopentutorials.com/examples/java-ee/jax-ws/create-and-consume-web-service-using-jax-ws/ ) I managed use JAX-WS tool called 'wsimport' for generating the artifacts required for creating and consuming a web service. 遵循本教程( http://theopentutorials.com/examples/java-ee/jax-ws/create-and-consume-web-service-using-jax-ws/ )之后,我设法使用了名为“ wsimport”的JAX-WS工具用于生成创建和使用Web服务所需的工件。 'wsimport' takes a wsdl file as input. “ wsimport”将wsdl文件作为输入。 It compiled well besides one warning for what I think is not critical (or maybe it is?) 除了对我认为不重要的警告(或者也许是警告)发出警告以外,它的编译效果还不错。

C:\\Users\\Nenad\\eclipseJunoSESR2\\GettingStartedWithEclipseJuno\\SOAConsume02>wsimport -s src -d bin http://i3770k.mshome.net:8001/soa-infra/services/default/POProcessing/receivePO?WSDL C:\\ Users \\ Nenad \\ eclipseJunoSESR2 \\ GettingStartedWithEclipseJuno \\ SOAConsume02> wsimport -s src -d bin http://i3770k.mshome.net:8001/soa-infra/services/default/POProcessing/receivePO?WSDL

parsing WSDL... 解析WSDL ...

[WARNING] R2716 WSI-BasicProfile ver. [警告] R2716 WSI-BasicProfile版本。 1.0, namespace attribute not allowed in doc/lit for soapbind:body: "execute" line 31 of http://i3770k.mshome.net:8001/soa-infra/services/default/POProcessing/receivePO?WSDL 1.0,SOAP / bind:body:“执行” http://i3770k.mshome.net:8001/soa-infra/services/default/POProcessing/receivePO?WSDL的第31行,doc / lit中不允许使用名称空间属性

generating code... compiling code... 生成代码...编译代码...

C:\\Users\\Nenad\\eclipseJunoSESR2\\GettingStartedWithEclipseJuno\\SOAConsume02> C:\\ Users \\ Nenad \\ eclipseJunoSESR2 \\ GettingStartedWithEclipseJuno \\ SOAConsume02>

So the classes are there: 这样的类就在那里:

在此处输入图片说明

And now I am stuck, because I have no idea how to send "order" ie how to populate input arguments: 现在我被困住了,因为我不知道如何发送“命令”,即如何填充输入参数:

request PurchaseOrderType * CustID string Value * ID string Value productName string itemType string price decimal quantity decimal status string ccType string ccNumber 请求PurchaseOrderType * CustID字符串值* ID字符串值productName字符串itemType字符串价格十进制数量十进制状态字符串ccType字符串ccNumber

In eclipse I created SOAClient class such as: 在eclipse中,我创建了SOAClient类,例如:

package com.oracle.client;

import java.math.BigDecimal;

import com.oracle.sca.soapservice.poprocessing.poprocessing.receivepo.ReceivePO;
import com.oracle.xmlns.ns.order.PurchaseOrderType;

public class SOAClient {
    public static void main(String[] args) {

        ReceivePO receivePO = new ReceivePO();
        PurchaseOrderType pot = new PurchaseOrderType();

        pot.setCustID("1111");
        pot.setID("2121");
        pot.setProductName("Bluetooth Headset");
        pot.setItemType("Electronics");
        BigDecimal bd_p = new BigDecimal("49.99");
        pot.setPrice(bd_p);
        BigDecimal bd_q = new BigDecimal("1000");
        pot.setQuantity(bd_q);
        pot.setStatus("initial");
        pot.setCcType("Mastercard");
        pot.setCcNumber("8765-8765-8765-8765");

    }
}

auto generated class ExecutePtt looks like: 自动生成的类ExecutePtt看起来像:

package com.oracle.sca.soapservice.poprocessing.poprocessing.receivepo;

import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
import com.oracle.xmlns.ns.order.ObjectFactory;
import com.oracle.xmlns.ns.order.PurchaseOrderType;


/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.6 in JDK 6
 * Generated source version: 2.1
 * 
 */
@WebService(name = "execute_ptt", targetNamespace = "http://oracle.com/sca/soapservice/POProcessing/POProcessing/receivePO")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
    ObjectFactory.class
})
public interface ExecutePtt {


    /**
     * 
     * @param request
     */
    @WebMethod(action = "execute")
    @Oneway
    public void execute(
        @WebParam(name = "PurchaseOrder", targetNamespace = "http://xmlns.oracle.com/ns/order", partName = "request")
        PurchaseOrderType request);

}

ReceivePO class is: ReceivePO类是:

package com.oracle.sca.soapservice.poprocessing.poprocessing.receivepo;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;


/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.6 in JDK 6
 * Generated source version: 2.1
 * 
 */
@WebServiceClient(name = "receivePO", targetNamespace = "http://oracle.com/sca/soapservice/POProcessing/POProcessing/receivePO", wsdlLocation = "http://i3770k.mshome.net:8001/soa-infra/services/default/POProcessing/receivePO?WSDL")
public class ReceivePO
    extends Service
{

    private final static URL RECEIVEPO_WSDL_LOCATION;
    private final static Logger logger = Logger.getLogger(com.oracle.sca.soapservice.poprocessing.poprocessing.receivepo.ReceivePO.class.getName());

    static {
        URL url = null;
        try {
            URL baseUrl;
            baseUrl = com.oracle.sca.soapservice.poprocessing.poprocessing.receivepo.ReceivePO.class.getResource(".");
            url = new URL(baseUrl, "http://i3770k.mshome.net:8001/soa-infra/services/default/POProcessing/receivePO?WSDL");
        } catch (MalformedURLException e) {
            logger.warning("Failed to create URL for the wsdl Location: 'http://i3770k.mshome.net:8001/soa-infra/services/default/POProcessing/receivePO?WSDL', retrying as a local file");
            logger.warning(e.getMessage());
        }
        RECEIVEPO_WSDL_LOCATION = url;
    }

    public ReceivePO(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public ReceivePO() {
        super(RECEIVEPO_WSDL_LOCATION, new QName("http://oracle.com/sca/soapservice/POProcessing/POProcessing/receivePO", "receivePO"));
    }

    /**
     * 
     * @return
     *     returns ExecutePtt
     */
    @WebEndpoint(name = "execute_pt")
    public ExecutePtt getExecutePt() {
        return super.getPort(new QName("http://oracle.com/sca/soapservice/POProcessing/POProcessing/receivePO", "execute_pt"), ExecutePtt.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns ExecutePtt
     */
    @WebEndpoint(name = "execute_pt")
    public ExecutePtt getExecutePt(WebServiceFeature... features) {
        return super.getPort(new QName("http://oracle.com/sca/soapservice/POProcessing/POProcessing/receivePO", "execute_pt"), ExecutePtt.class, features);
    }

}

ObjectFactory class is: ObjectFactory类为:

package com.oracle.xmlns.ns.order;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;


/**
 * This object contains factory methods for each 
 * Java content interface and Java element interface 
 * generated in the com.oracle.xmlns.ns.order package. 
 * <p>An ObjectFactory allows you to programatically 
 * construct new instances of the Java representation 
 * for XML content. The Java representation of XML 
 * content can consist of schema derived interfaces 
 * and classes representing the binding of schema 
 * type definitions, element declarations and model 
 * groups.  Factory methods for each of these are 
 * provided in this class.
 * 
 */
@XmlRegistry
public class ObjectFactory {

    private final static QName _PurchaseOrder_QNAME = new QName("http://xmlns.oracle.com/ns/order", "PurchaseOrder");

    /**
     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.oracle.xmlns.ns.order
     * 
     */
    public ObjectFactory() {
    }

    /**
     * Create an instance of {@link PurchaseOrderType }
     * 
     */
    public PurchaseOrderType createPurchaseOrderType() {
        return new PurchaseOrderType();
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link PurchaseOrderType }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "http://xmlns.oracle.com/ns/order", name = "PurchaseOrder")
    public JAXBElement<PurchaseOrderType> createPurchaseOrder(PurchaseOrderType value) {
        return new JAXBElement<PurchaseOrderType>(_PurchaseOrder_QNAME, PurchaseOrderType.class, null, value);
    }

}

package-info is 包信息是

@javax.xml.bind.annotation.XmlSchema(namespace = "http://xmlns.oracle.com/ns/order", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.oracle.xmlns.ns.order;

and

PurchaseOrderType class is PurchaseOrderType类为

package com.oracle.xmlns.ns.order;

import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for PurchaseOrderType complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="PurchaseOrderType">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="CustID" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="ID" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="productName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="itemType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="price" type="{http://www.w3.org/2001/XMLSchema}decimal" minOccurs="0"/>
 *         &lt;element name="quantity" type="{http://www.w3.org/2001/XMLSchema}decimal" minOccurs="0"/>
 *         &lt;element name="status" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="ccType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="ccNumber" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PurchaseOrderType", propOrder = {
    "custID",
    "id",
    "productName",
    "itemType",
    "price",
    "quantity",
    "status",
    "ccType",
    "ccNumber"
})
public class PurchaseOrderType {

    @XmlElement(name = "CustID", required = true)
    protected String custID;
    @XmlElement(name = "ID", required = true)
    protected String id;
    protected String productName;
    protected String itemType;
    protected BigDecimal price;
    protected BigDecimal quantity;
    protected String status;
    protected String ccType;
    protected String ccNumber;

    /**
     * Gets the value of the custID property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCustID() {
        return custID;
    }

    /**
     * Sets the value of the custID property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCustID(String value) {
        this.custID = value;
    }

    /**
     * Gets the value of the id property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getID() {
        return id;
    }

    /**
     * Sets the value of the id property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setID(String value) {
        this.id = value;
    }

    /**
     * Gets the value of the productName property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getProductName() {
        return productName;
    }

    /**
     * Sets the value of the productName property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setProductName(String value) {
        this.productName = value;
    }

    /**
     * Gets the value of the itemType property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getItemType() {
        return itemType;
    }

    /**
     * Sets the value of the itemType property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setItemType(String value) {
        this.itemType = value;
    }

    /**
     * Gets the value of the price property.
     * 
     * @return
     *     possible object is
     *     {@link BigDecimal }
     *     
     */
    public BigDecimal getPrice() {
        return price;
    }

    /**
     * Sets the value of the price property.
     * 
     * @param value
     *     allowed object is
     *     {@link BigDecimal }
     *     
     */
    public void setPrice(BigDecimal value) {
        this.price = value;
    }

    /**
     * Gets the value of the quantity property.
     * 
     * @return
     *     possible object is
     *     {@link BigDecimal }
     *     
     */
    public BigDecimal getQuantity() {
        return quantity;
    }

    /**
     * Sets the value of the quantity property.
     * 
     * @param value
     *     allowed object is
     *     {@link BigDecimal }
     *     
     */
    public void setQuantity(BigDecimal value) {
        this.quantity = value;
    }

    /**
     * Gets the value of the status property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getStatus() {
        return status;
    }

    /**
     * Sets the value of the status property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setStatus(String value) {
        this.status = value;
    }

    /**
     * Gets the value of the ccType property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCcType() {
        return ccType;
    }

    /**
     * Sets the value of the ccType property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCcType(String value) {
        this.ccType = value;
    }

    /**
     * Gets the value of the ccNumber property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCcNumber() {
        return ccNumber;
    }

    /**
     * Sets the value of the ccNumber property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCcNumber(String value) {
        this.ccNumber = value;
    }

}

Therfore my questions are: 因此,我的问题是:

  1. What should I add in my class SOAClient to make this work (set the parameters and execute test - place order) 我应该在类SOAClient中添加什么来完成这项工作(设置参数并执行测试-下订单)

  2. Should I use JAX-WS at all? 我应该完全使用JAX-WS吗? I ask because i saw some tutorials without it but i haven't still studied them. 我问是因为我看到了一些没有它的教程,但是我仍然没有研究它们。

Once when I found it, solution looks quite easy. 一旦找到它,解决方案看起来就很容易。 Here is the class that did the job right: 这是完成工作的课程:

package com.oracle.client;

import java.math.BigDecimal;

import com.oracle.sca.soapservice.poprocessing.poprocessing.receivepo.ExecutePtt;
import com.oracle.sca.soapservice.poprocessing.poprocessing.receivepo.ReceivePO;
import com.oracle.xmlns.ns.order.ObjectFactory;
import com.oracle.xmlns.ns.order.PurchaseOrderType;

public class SOAClient {
    public static void main(String[] args) {

        ReceivePO recPOService = new ReceivePO();
        ExecutePtt recPOPort = recPOService.getExecutePt();
        PurchaseOrderType purchaseOrder = new ObjectFactory()
                .createPurchaseOrderType();

        purchaseOrder.setCustID("1111");
        purchaseOrder.setID("2121");
        purchaseOrder.setProductName("Bluetooth Headset");
        purchaseOrder.setItemType("Electronics");
        BigDecimal bd_p = new BigDecimal("49.99");
        purchaseOrder.setPrice(bd_p);
        BigDecimal bd_q = new BigDecimal("10");
        purchaseOrder.setQuantity(bd_q);
        purchaseOrder.setStatus("initial");
        purchaseOrder.setCcType("Mastercard");
        purchaseOrder.setCcNumber("8765-8765-8765-8765");

        recPOPort.execute(purchaseOrder);

    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM