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 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?