简体   繁体   English

在java中使用axis调用webservice

[英]Call webservice using axis in java

When I would like to call webservice using Axis the request looks like this: 当我想使用Axis调用webservice时,请求如下所示:

<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
    <env:Header/>
    <env:Body>
        <ns2:pobierzWarunkiCenowe xmlns:ns2="http://something">
            <parametryWarunkowCenowych>
                <parametryWarunkuCenowego>
                    <KOMG-ZZPROMOCJA>KAUCYJNY</KOMG-ZZPROMOCJA>
                    <KOMG-KUNNR>502582</KOMG-KUNNR>
                    <KOMG-MATNR>TELATP00053</KOMG-MATNR>
                    <RV13A-DATAB>2014-04-11+02:00</RV13A-DATAB>
                </parametryWarunkuCenowego>
            </parametryWarunkowCenowych>
            <metryka>
                <uzytkownik>user</uzytkownik>
                <system>system</system>
                <data>2014-04-11T08:43:31.081+02:00</data>
                <uid>uid</uid>
            </metryka>
        </ns2:pobierzWarunkiCenowe>
    </env:Body>
</env:Envelope>

I try to debug this operation and I said that object is filled with correct values. 我尝试调试此操作,我说该对象填充了正确的值。

package cenniki;

import java.io.Serializable;
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 parametryWarunkowCenowych complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="parametryWarunkowCenowych">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="parametryWarunkuCenowego" type="{http://something"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "parametryWarunkowCenowych", propOrder = {
    "parametryWarunkuCenowego"
})
public class ParametryWarunkowCenowych
    implements Serializable
{

    private final static long serialVersionUID = 1L;
    @XmlElement(required = true)
    protected ParametryWarunkuCenowego parametryWarunkuCenowego;

    /**
     * Gets the value of the parametryWarunkuCenowego property.
     * 
     * @return
     *     possible object is
     *     {@link ParametryWarunkuCenowego }
     *     
     */
    public ParametryWarunkuCenowego getParametryWarunkuCenowego() {
        return parametryWarunkuCenowego;
    }

    /**
     * Sets the value of the parametryWarunkuCenowego property.
     * 
     * @param value
     *     allowed object is
     *     {@link ParametryWarunkuCenowego }
     *     
     */
    public void setParametryWarunkuCenowego(ParametryWarunkuCenowego value) {
        this.parametryWarunkuCenowego = value;
    }

}

ParametryWarunkuCenowego is not null. ParametryWarunkuCenowego不为null。 So why sometimes it send: 那么为什么有时会发送:

<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
    <env:Header/>
    <env:Body>
        <ns1:pobierzWarunkiCenowe xmlns:ns1='http://something' xsi:nil='1' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'/>
    </env:Body>
</env:Envelope>

Is this is ur total code for the class parametryWarunkowCenowych then u have to add the code for the inner class also as mention below for the proper conversion of the class in the xml format. 这是类parametryWarunkowCenowych的总代码,那么你必须添加内部类的代码,如下所述,以正确的xml格式转换类。

            @XmlAccessorType(XmlAccessType.FIELD)
            @XmlType(name = "pobierzWarunkiCenowe ", propOrder = { "data" })
            public class pobierzWarunkiCenowe  {
                @XmlAccessorType(XmlAccessType.FIELD)
                @XmlType(name = "", propOrder = { "parametryWarunkowCenowych" })
                public static class parametryWarunkowCenowych { 
                This xml should be declared here
                    <KOMG-ZZPROMOCJA>KAUCYJNY</KOMG-ZZPROMOCJA>
                    <KOMG-KUNNR>502582</KOMG-KUNNR>
                    <KOMG-MATNR>TELATP00053</KOMG-MATNR>
                    <RV13A-DATAB>2014-04-11+02:00</RV13A-DATAB>


                }
                // similar way for the metryka 
                protected pobierzWarunkiCenowe .parametryWarunkowCenowych data;

                public pobierzWarunkiCenowe .parametryWarunkowCenowych getData() {
                    return data;
                }


                public void setData(pobierzWarunkiCenowe.parametryWarunkowCenowych value) {
                    this.data = value;
                }

            }

I found the answer. 我找到了答案。 In my EJB Stateless bean i get port from service in @PostConstruct method. 在我的EJB无状态bean中,我从@PostConstruct方法中获取服务端口。 When i move this code to the method where operation is call i can call this operation in separate ports with multiple threads. 当我将此代码移动到调用操作的方法时,我可以在具有多个线程的单独端口中调用此操作。

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

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