Magento Java SOAP客户端

时间:2011-11-28 11:12:28

标签: java magento soap cxf

我开始使用apache cxf开发一个java客户端。我试图登录并创建一个调用来获取我的洋红色安装商店列表。这找不到了。但后来我试图收到网店的所有产品清单。现在我收到一条有趣的错误消息!

我正在使用Magento 1.6.1.0并且它以ws-i模式运行!

    URL wsdlURL = new URL("http://someurl/api/v2_soap/?wsdl=1");

    MagentoService ss = new MagentoService(wsdlURL, SERVICE_NAME);
    MageApiModelServerWsiHandlerPortType port = ss.getMageApiModelServerWsiHandlerPort();

    LoginParam loginParam = new LoginParam();
    loginParam.setApiKey("password");
    loginParam.setUsername("user");

    LoginResponseParam sessionId = port.login(loginParam);
    System.out.println("sessionId : " + sessionId.getResult());

    StoreListRequestParam param = new StoreListRequestParam();
    param.setSessionId(sessionId.getResult());
    StoreListResponseParam storeListRespParam = port.storeList(param);
    StoreEntityArray storeEntityArray = storeListRespParam.getResult();
    List<StoreEntity> stores = storeEntityArray.getComplexObjectArray();
    System.out.println(">>>> " + stores.size());

    StoreEntity store = stores.get(0);

    CatalogProductListRequestParam params = new CatalogProductListRequestParam();
    params.setSessionId(sessionId.getResult());
    params.setFilters(null);
    params.setStore(String.valueOf(store.getStoreId()));

    CatalogProductListResponseParam response = port.catalogProductList(params);
    CatalogProductEntityArray catalogProdEntityArray = response.getResult();
    List<CatalogProductEntity> products = catalogProdEntityArray.getComplexObjectArray();
    System.out.println(">>>> " + products.size());

错误消息:

[com.ctc.wstx.exc.WstxEOFException:意外的EOF;期待元素的关键标记

似乎回复的结构有问题!?

有人有个主意!?

提前致谢

整个堆栈跟踪:

 Interceptor for {urn:Magento}MagentoService#{urn:Magento}catalogProductList has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error: Unexpected EOF; was expecting a close tag for element <sku>
 at [row,col {unknown-source}]: [3336,6] 
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:824)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:644)
    at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:156)
    at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:201)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:801)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1627)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1494)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1402)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:649)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:535)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:465)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:368)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:321)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
    at $Proxy24.catalogProductList(Unknown Source)
    at Client.main(Client.java:53)
Caused by: javax.xml.bind.UnmarshalException
 - with linked exception:
[com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <sku>
 at [row,col {unknown-source}]: [3336,6]]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:426)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.doUnmarshal(JAXBEncoderDecoder.java:784)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.access$100(JAXBEncoderDecoder.java:96)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder$1.run(JAXBEncoderDecoder.java:812)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:810)
    ... 20 more
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <sku>
 at [row,col {unknown-source}]: [3336,6]
    at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)
    at com.ctc.wstx.sr.BasicStreamReader.throwUnexpectedEOF(BasicStreamReader.java:5466)
    at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2685)
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1050)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:192)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
    ... 26 more
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: Unexpected EOF; was expecting a close tag for element <sku>
 at [row,col {unknown-source}]: [3336,6] 
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)
    at $Proxy24.catalogProductList(Unknown Source)
    at Client.main(Client.java:53)
Caused by: javax.xml.bind.UnmarshalException
 - with linked exception:
[com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <sku>
 at [row,col {unknown-source}]: [3336,6]]
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:426)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.doUnmarshal(JAXBEncoderDecoder.java:784)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.access$100(JAXBEncoderDecoder.java:96)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder$1.run(JAXBEncoderDecoder.java:812)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:810)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:644)
    at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:156)
    at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:201)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:801)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1627)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1494)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1402)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:649)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:535)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:465)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:368)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:321)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
    ... 2 more
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element <sku>
 at [row,col {unknown-source}]: [3336,6]
    at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)
    at com.ctc.wstx.sr.BasicStreamReader.throwUnexpectedEOF(BasicStreamReader.java:5466)
    at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2685)
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1050)
    at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:192)
    at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
    ... 26 more

0 个答案:

没有答案