使用SoapClient时出错,但使用网络浏览器时出错

时间:2016-10-11 13:43:11

标签: php web-services soap

使用Chronopost Web服务。

在网络浏览器中使用此帖后HTTP请求时(帐号和密码隐藏在那里,因此除非您拥有Chronopost ID,否则无法自行测试):

https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS/shippingWithReservationAndESDWithRefClientPC?subAccount=000&accountNumber=ACCOUNT_NUMBER&password=PASSWORD&shipperCivility=E&shipperName=DELBET&shipperName2=RICHARD&shipperAdress1=1%20rue%20des%20accents&shipperZipCode=28500&shipperCity=Ste%20Gemme%20Moronval&shipperCountry=FR&shipperCountryName=France&shipperContactName=Richard%20Delbet&shipperEmail=richard.delbet@telintrans.fr&shipperPhone=0123456789&shipperMobilePhone=0601020304&recipientCivility=E&recipientName=MALKA&recipientName2=DAVID&recipientAdress1=1%20rue%20des%20essais&recipientZipCode=75001&recipientCity=Paris&recipientCountry=FR&recipientCountryName=France&recipientContactName=David%20Malka&recipientEmail=david.malka@telintrans.fr&recipientPhone=0222426789&recipientMobilePhone=0622220304&shipperRef=CMD1&recipientRef=ART1&productCode=01&shipDate=27/07/2010%2010:00:00&shipHour=10&weight=2&service=0&objectType=MAR&modeRetour=1&mode=PDF

我对所有正确的数据都有一个有效的回复。

使用具有完全相同参数的SoapClient时:

$client = new \SoapClient("http://ws.chronopost.fr/shipping-cxf/ShippingServiceWS?wsdl");
    $data = [
      'subAccount' => '000',
      'accountNumber' => ACCOUNT_NUMBER,
      'password' => PASSWORD,
      'shipperCivility' => 'E',
      'shipperName' => 'DELBET',
      'shipperName2' => 'RICHARD',
      'shipperAdress1' => '1%20rue%20des%20accents',
      'shipperZipCode' => '28500',
      'shipperCity' => 'Ste%20Gemme%20Moronval',
      'shipperCountry' => 'FR',
      'shipperCountryName' => 'France',
      'shipperContactName' => 'Richard%20Delbet',
      'shipperEmail' => 'richard.delbet@telintrans.fr',
      'shipperPhone' => '0123456789',
      'shipperMobilePhone' => '0601020304',
      'recipientCivility' => 'E',
      'recipientName' => 'MALKA',
      'recipientName2' => 'DAVID',
      'recipientAdress1' => '1%20rue%20des%20essais',
      'recipientZipCode' => '75001',
      'recipientCity' => 'Paris',
      'recipientCountry' => 'FR',
      'recipientCountryName' => 'France',
      'recipientContactName' => 'David%20Malka',
      'recipientEmail' => 'david.malka@telintrans.fr',
      'recipientPhone' => '0222426789',
      'recipientMobilePhone' => '0622220304',
      'shipperRef' => 'CMD1',
      'recipientRef' => 'ART1',
      'productCode' => '01',
      'shipDate' => '27/07/2010%2010:00:00',
      'shipHour' => '10',
      'weight' => '2',
      'service' => '0',
      'objectType' => 'MAR',
      'modeRetour' => '1',
      'mode' => 'PDF',
    ];
    $response = $client->__soapCall("shippingWithReservationAndESDWithRefClientPC", array($data));

我退回了一条错误:

  

object(stdClass)#531(1){[" return"] => object(stdClass)#537(2){       ["的errorCode"] =>       INT(1)       ["的errorMessage"] =>       字符串(3112)" fr.chronopost.soap.shipping.exception.ValidateException at   fr.chronopost.soap.shipping.util.PopulateUtils.populateSkybill(PopulateUtils.java:355)     在   fr.chronopost.soap.shipping.cxf.ShippingServiceWS.shippingWithReservationAndESDWithRefClientPC(ShippingServiceWS.java:615)     在sun.reflect.GeneratedMethodAccessor1258.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:606)at   org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:136)     在   org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82)     在   org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:54)     在   org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68)     在   org.apache.cxf.interceptor.ServiceInvokerInterceptor $ 1.run(ServiceInvokerInterceptor.java:56)     在   org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)     在   org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:92)     在   org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)     在   org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)     在   org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92)     在   org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:285)     在   org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:168)     在   org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:175)     在   org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:153)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:637)at   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)at at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)     在   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)     在   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)     在   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)     在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)     在   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)     在   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)     在   org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)     在   org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)     在org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)     在   org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)     在   org.apache.jk.common.ChannelSocket $ SocketConnection.runIt(ChannelSocket.java:898)     在   org.apache.tomcat.util.threads.ThreadPool $ ControlRunnable.run(ThreadPool.java:690)     在java.lang.Thread.run(Thread.java:744)" }}

不幸的是,错误代码" 1"在文档中描述为"系统错误"。

一个人可能无法直接帮助我了解Chronopost Web服务,但也许我在PHP SoapClient对象中遗漏了一些东西。

使用Web浏览器时为什么我有正确的响应?使用SoapClient时出现某种ValidateException错误?

1 个答案:

答案 0 :(得分:2)

进行SOAP调用时,不需要包含URL编码的数据字符串。 Php soapclient自动将数据编码为XML。因此问题很可能是服务对您的数据执行的验证,并且它在%字符上窒息。尝试更改

'shipDate' => '27/07/2010%2010:00:00'

'shipDate' => '27/07/2010 10:00:00'