次のように php で Web サービス インターフェイス コードを作成しました
<?phpheader('Content-Type: text/html; charset=utf-8');define('IN_ECS', true);$server = new soap_server();$server->configureWSDL('ecshopping webservices', 'urn:wsdl');$server->wsdl->schemaTargetNamespace = 'urn:wsdl';$server->register('test', // method name array('name' => 'xsd:string'), // input parameters array('return' => 'xsd:string') // output parameters);function test($name) { $f = fopen("check_debug.txt","a+"); fwrite($f,"char=".charToGBK($name)); fclose($f); return '传入字符串为: ' . charToGBK($name);}$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';$server->service($HTTP_RAW_POST_DATA);?>
Java で呼び出されます
public class Test { /** * @param args */ public static void main(String[] args) throws Exception { String endpoint = "http://192.168.5.10:8080/shopping2013/Dragon/Service.php";Service service = new Service(); Call call = (Call) service.createCall();// 通过service创建call对象 // 设置service所在URL call.setTargetEndpointAddress(new java.net.URL(endpoint)); String ret = null; call.setOperationName("test"); ret=call.invoke(new String[]{new String("我是一个兵".getBytes(),"ISO-8859-1")}).toString(); System.out.println(new String(ret.getBytes("ISO-8859-1"),"GBK")); }}
ローカル マシン (win7/xp) の php Web サービスには問題ありませんが、Linux ではエラーが報告されます:
スレッドでの例外"main" AxisFault
fastCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
fallSubcode:
fallString: org.xml.sax.SAXException: 不正なエンベロープ タグ: br
fastActor:
fastNode :
fastDetail :
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: 不正なエンベロープ タグ: br
org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder. java:71 )
org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
com .sun.org.apache.xercess.internal.parsers.abstractxmlDocumentparser.emptyelement (abstractxmldocumentparser.java:179)
.internal.impl.xmlnsdocumentScannerimpl.SCANSTARTELEMENT (xmlnsdocumentscannerimpl.java:377) com.sun.org.apache .xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl . java:3095)
でcom.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:922)
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl .next(XMLDocumentScannerImpl.java: 648)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration) .java:807)
com.sun.org.apache.xerces.internal で .parsers.XML11Configuration.parse(XML11Configuration.java:737)
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse で(XMLParser.java:107)
com.sun.org.apache.xerces .internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl $JAXPSAXParser.parse(SAXParserImpl.java:522)
javax.xml.parsers .SAXParser.parse(SAXParser.java:395)
org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) で
org.apache.axis.Message.getSOAPEnvelope(Message.java:435) で
org.apache.axis.handlers.soap.MustUnderstandChecker.invoke で(MustUnderstandChecker.java:62)
org.apache.axis.client.AxisClient .invoke(AxisClient.java:206)
org.apache.axis.client.Call.invokeEngine(Call.java:2784)
org .apache.axis.client.Call.invoke(Call.java:2767)
org.apache.axis.client.Call.invoke(Call.java:2443)
org.apache.axis.client.Call.invoke (Call.java:2366)
org.apache.axis.client.Call .invoke(Call.java:1812) で
test.TestGoods.main(TestGoods.java:53) で
{http://xml. apache.org/axis/}ホスト名:luolei
org.xml.sax. SAXException: 不正なエンベロープ タグ: br
org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
org.apache.axis .SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
org.apache.axis .Message.getSOAPEnvelope(Message.java:435)
org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) )
org.apache.axis.client.AxisClient.invoke(AxisClient.java :206) で
org.apache.axis.client.Call.invokeEngine(Call.java:2784) で
org.apache.axis.client で.Call.invoke(Call.java:2767)
org.apache.axis で .client.Call.invoke(Call.java:2443)
org.apache.axis.client.Call.invoke(Call.java:2366) )
org.apache.axis.client.Call.invoke(Call.java :1812)
test.TestGoods.main(TestGoods.java:53)
原因: org.xml.sax.SAXException: 不正なエンベロープ タグ: br
org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:71)
org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179) )
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScan)ナーインプル.java:626)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3095)
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl $PrologDriver.next(XMLDocumentScannerImpl.java:922)
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
com.sun.org.apache.xerces.internal .impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
com.sun.org.apache.xerces .internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
com.sun.org.apache .xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
com.sun.org .apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
org.apache.axis.encoding.DeserializationContext .parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
... 9 もっと
回复讨论(解决方案)
在本机( win7/xp) 中没问题、就说明程序本自体は确的
linux の構成问题またはその他
你解释一下 java 的错误信息都说了何么
本機 (win7/xp) 中没问题、就说明程序本身は确的
可能性は linux の構成问题またはその他
你解释一下 java 的错误信息都说了什么
java 报错是一通用错误,只是希望到过相错语の亲们、提供点解决思路