Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从PHP调用Web服务_Java_Php_Web Services_Wsdl_Soap Client - Fatal编程技术网

Java 从PHP调用Web服务

Java 从PHP调用Web服务,java,php,web-services,wsdl,soap-client,Java,Php,Web Services,Wsdl,Soap Client,我一直在尝试从下到上调用用java创建的Web服务,并希望通过我的PHP文件调用它,但它总是给我一个错误 我尝试过的代码: $client = new SoapClient("http://localhost:8080/Indexer/services/IndexerService?wsdl"); $params = array( 'anId' => 3, 'action' => 'OMNOMNOMNOM', 'parameters' =>

我一直在尝试从下到上调用用java创建的Web服务,并希望通过我的PHP文件调用它,但它总是给我一个错误

我尝试过的代码:

$client = new SoapClient("http://localhost:8080/Indexer/services/IndexerService?wsdl");
$params = array(
      'anId' => 3,
      'action' => 'OMNOMNOMNOM',
      'parameters' => array(
                  'Param' => array(
                          array('Name' => 'in0', 'Value' => 'Skinnarlyngen startar Välkommen')
      )
));
$result = $client->__soapCall("getIds",$params);

print_r($result);
我尝试的第二段代码:

$wsdl = 'http://localhost:8080/Indexer/services/IndexerService?wsdl';   
  $client = new SoapClient($wsdl );

  print($client->getIds("ibm"));
我的Web服务在使用java客户端进行尝试时提供了完美的结果:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:tns="http://labs.aroha.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" targetNamespace="http://labs.aroha.com">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://labs.aroha.com">
<xsd:element name="example">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="exampleResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="exampleRequest">
<wsdl:part name="parameters" element="tns:example"></wsdl:part>
</wsdl:message>
<wsdl:message name="exampleResponse">
<wsdl:part name="parameters" element="tns:exampleResponse"></wsdl:part>
</wsdl:message>
<wsdl:portType name="IndexerServicePortType">
<wsdl:operation name="example">
<wsdl:input name="exampleRequest" message="tns:exampleRequest"></wsdl:input>
<wsdl:output name="exampleResponse" message="tns:exampleResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="IndexerServiceHttpBinding" type="tns:IndexerServicePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="example">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="exampleRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="exampleResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="IndexerService">
<wsdl:port name="IndexerServiceHttpPort" binding="tns:IndexerServiceHttpBinding">
<wsdlsoap:address location="http://localhost:8080/Indexer/services/IndexerService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
有谁能帮助我用php代码调用java编写的Web服务吗


我想提到的是,我正在使用PHP5,并且wamp已经在我的php中启用了soap扩展。

您可以使用的一个很好的工具是,它将为您创建类等。

使用以下代码

 $Url = "http://localhost:8080/Indexer/services/IndexerService?wsdl";
    $params = array ("param1" =>"value","parm2"=>"value");

    $httpQuery = http_build_query ($params);
    $contextData = array (
                    "method" => "POST",
            "header" => "Connection: close\r\n".
                    "Content-Length: ".strlen($httpQuery)."\r\n",
                    "content"=> $httpQuery );               

    $context = stream_context_create (array ( "http" => $contextData )); 
    $result =  file_get_contents ($Url, false, $context); 

您可以使用file\u get\u contents($url)将WSDL加载到PHP中吗?这是一个PHP配置设置,不允许它访问它吗?是的,我可以从文件中加载它,甚至在ie中也看到了它。经过这么长时间的努力,我出现了这个错误:……信息:错误发生了!org.codehaus.xfire.fault.XFireFault:没有收到足够的操作消息部分。
 $Url = "http://localhost:8080/Indexer/services/IndexerService?wsdl";
    $params = array ("param1" =>"value","parm2"=>"value");

    $httpQuery = http_build_query ($params);
    $contextData = array (
                    "method" => "POST",
            "header" => "Connection: close\r\n".
                    "Content-Length: ".strlen($httpQuery)."\r\n",
                    "content"=> $httpQuery );               

    $context = stream_context_create (array ( "http" => $contextData )); 
    $result =  file_get_contents ($Url, false, $context);