douzhulan1815 2015-03-24 16:57
浏览 148

PHP Soap客户端,Java SOAP服务器

I am writing PHP SOAP client that will connect to Java SOAP web service and the cliente needs to fetch some data from web service.

Web service wsdl files:

http://test.iaeste.net:8080/iws-ws/accessWS?wsdl

http://test.iaeste.net:8080/iws-ws/exchangeWS?wsdl

My code:

<?php
$soapURL = "http://test.iaeste.net:8080/iws-ws/accessWS?wsdl" ;
$options = array('features' => 
    SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS);
    $soapClient = new SoapClient($soapURL, $options);
$soapResult = $soapClient->generateSession(Array("password"=>"mypassword", "username"=> "myusername")) ;
var_dump($soapResult);
$token = $soapResult->token->token;
$obj= new stdClass();
$obj->exchangeYear=2015;
$obj->fetchType="SHARED";
$obj->token=$token;
$soapURL = "http://test.iaeste.net:8080/iws-ws/exchangeWS?wsdl" ;
$soapClient2 = new SoapClient($soapURL, $options);
$soapResult2 = $soapClient2->fetchOffers($obj) ;
//$soapResult2 = $soapClient2->fetchOffers(Array("exchangeYear"=> 2015,"fetchType"=>"SHARED" , "token"=>"$token" )) ;
var_dump($soapResult2);
echo "<br>";
$soapResult = $soapClient->deprecateSession(Array("token"=>"$token")) ;
var_dump($soapResult);
?>

Everything works correctly except fetchOffers method. I have also tried to send array instead of object. It is commented in code, but the result is the same. soapResult2 variable output is:

object(stdClass)#9 (2) { ["error"]=> object(stdClass)#10 (2) { ["error"]=> int(401) ["description"]=> string(54) "Given data is insufficient to properly handle request." } ["message"]=> string(57) "Validation failed: {fetchType=The field may not be null.}" } 

I am little bit puzzeld with this problem, since it should work. I also have fetchType Java class and fetchOfferRequest Java class from web service, to properlly see how to format the objects.

FetchOfferRequest:

package net.iaeste.iws.ws;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for fetchOffersRequest complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="fetchOffersRequest">
 *   &lt;complexContent>
 *     &lt;extension base="{http://ws.iws.iaeste.net/}abstractPaginatable">
 *       &lt;sequence>
 *         &lt;element name="exchangeYear" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
 *         &lt;element name="fetchType" type="{http://ws.iws.iaeste.net/}fetchType" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/extension>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "fetchOffersRequest", propOrder = {
    "exchangeYear",
    "fetchType"
})
public class FetchOffersRequest
    extends AbstractPaginatable
{

    protected Integer exchangeYear;
    protected FetchType fetchType;

    /**
     * Gets the value of the exchangeYear property.
     * 
     * @return
     *     possible object is
     *     {@link Integer }
     *     
     */
    public Integer getExchangeYear() {
        return exchangeYear;
    }

    /**
     * Sets the value of the exchangeYear property.
     * 
     * @param value
     *     allowed object is
     *     {@link Integer }
     *     
     */
    public void setExchangeYear(Integer value) {
        this.exchangeYear = value;
    }

    /**
     * Gets the value of the fetchType property.
     * 
     * @return
     *     possible object is
     *     {@link FetchType }
     *     
     */
    public FetchType getFetchType() {
        return fetchType;
    }

    /**
     * Sets the value of the fetchType property.
     * 
     * @param value
     *     allowed object is
     *     {@link FetchType }
     *     
     */
    public void setFetchType(FetchType value) {
        this.fetchType = value;
    }

}

FetchType:

package net.iaeste.iws.ws;

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for fetchType.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * <p>
 * <pre>
 * &lt;simpleType name="fetchType">
 *   &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
 *     &lt;enumeration value="DOMESTIC"/>
 *     &lt;enumeration value="SHARED"/>
 *   &lt;/restriction>
 * &lt;/simpleType>
 * </pre>
 * 
 */
@XmlType(name = "fetchType")
@XmlEnum
public enum FetchType {

    DOMESTIC,
    SHARED;

    public String value() {
        return name();
    }

    public static FetchType fromValue(String v) {
        return valueOf(v);
    }

}

I belive that this is all the information needed to solve this problem. If anyone knows how to help me, I would appreciate it.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?