php版本5.3,使用php自身扩展做了个web service,
php web service 代码如下:
<?php
//ini_set("soap.wsdl_cache_enabled", 0);
include("/var/www/html/test/BioNetConstruct.php");
$server = new SoapServer("http://192.168.1.114/BioNet/SOAP/BIG_BioNet.wsdl");
$server->addFunction("BioNetConstruct");
$server->addFunction("test");
$server->addFunction(SOAP_FUNCTIONS_ALL);
$server->handle();
?>
###############################################
php client 代码及运行结果
<?php
$name = "sun jiya";
try{
$client = new SoapClient("http://192.168.1.114/BioNet/SOAP/BioNetConstructServer.php?wsdl");
$result = $client->test($name);
print_r($client->__getFunctions());
echo $result;
}catch(SoapFault $e){
print "Sorry an error was caught executing your request: {$e->getMessage()}";
}
?>
***********
运行结果:Array ( [0] => string BioNetConstruct(BioNetConstructParam $ParamArray) [1] => string test(string $name) ) Hello,sun jiya
有结果可知:存在test方法
########################################
我想用java调用php web service
代码:
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import java.util.*;import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;import org.apache.axis.client.Call;
import org.apache.axis.client.Service;public class BioNet {
public static String BioNetConstruct(){
Service service = new Service();
String Plugin_xgmml = "";
try{
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL("http://192.168.1.114/BioNet/SOAP/BioNetConstructServer.php")); 
QName qname = new QName("http://192.168.1.114/BioNet/SOAP/BioNetConstructServer.php","test");
call.setOperationName(qname);
String name = "sunjiya";
call.addParameter("name",org.apache.axis.Constants.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
Object obj=call.invoke(new Object[]{name});
Plugin_xgmml=obj.toString();

}catch(ServiceException e1){
System.out.println("Service is abnomal!");
}catch(MalformedURLException e2){
System.out.println("setTargetEndpointAddress is abnomal!");
}catch(RemoteException e3){
System.out.println("invoke is abnomal!");
System.out.println(e3.getMessage());
System.out.println(e3.getCause());
e3.printStackTrace();
}
return Plugin_xgmml;
}
public static void main(String[] args){
System.out.println("::: call php webservice :::");
String str = BioNetConstruct();
System.out.println(str);
**************
运行结果:
::: call php webservice :::
invoke is abnomal!
Procedure 'test' not present
null
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
 faultSubcode: 
 faultString: Procedure 'test' not present
 faultActor: 
 faultNode: 
 faultDetail: 
{http://xml.apache.org/axis/}stackTrace:Procedure 'test' not present
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at BioNet.BioNetConstruct(BioNet.java:42)
at BioNet.main(BioNet.java:59) {http://xml.apache.org/axis/}hostname:sunjiyaProcedure 'test' not present
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at BioNet.BioNetConstruct(BioNet.java:42)
at BioNet.main(BioNet.java:59)为什么php测试正常,但是在java客户端调用服务就找不到方法?
在线等!!!