Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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
在PHP中使用WCF服务_Php_Wcf - Fatal编程技术网

在PHP中使用WCF服务

在PHP中使用WCF服务,php,wcf,Php,Wcf,我曾经使用Asp.net,但这是我学习php的第三天 我想使用一个非常基本的WCF web服务示例,并从php网站使用它。我举了一个例子: 我很确定我做的每件事都是按照显示的方式进行的,下面是php代码: <?php $wcfClient = new SoapClient('http://localhost:8732/Design_Time_Addresses/Translation/Service1/?wsdl'); $args = array('text' => 'Hello

我曾经使用Asp.net,但这是我学习php的第三天

我想使用一个非常基本的WCF web服务示例,并从php网站使用它。我举了一个例子:

我很确定我做的每件事都是按照显示的方式进行的,下面是php代码:

<?php

$wcfClient = new SoapClient('http://localhost:8732/Design_Time_Addresses/Translation/Service1/?wsdl');

$args = array('text' => 'Hello World');
$response = $wcfClient->ENtoJP($args);

echo $response->ENtoJPResult;
?>
但我在页面中仍然有以下错误:

致命错误:未捕获的SoapFault异常:[HTTP]无法处理该消息,因为内容类型为“text/xml;charset=utf-8“不是预期的类型”application/soap+xml;字符集=utf-8'。在C:\wamp\www\geogram.php:6堆栈跟踪:0[内部函数]:SoapClient->\uuu doRequest'http://localhos...“,”..”,1,01 C:\wamp\www\geogram.php6:SoapClient->调用'ENtoJP',数组2 C:\wamp\www\geogram.php6:SoapClient->ENtoJPArray 3{main}在第6行的C:\wamp\www\geogram.php中抛出

这是我的配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- Lors du déploiement du projet de bibliothèque du service, le contenu du fichier de configuration doit être ajouté au fichier app.config  
  de l'hôte. System.Configuration ne prend pas en charge les fichiers de configuration pour les bibliothèques. -->
  <system.serviceModel>
    <services>
      <service name="Translation.Translation">
        <endpoint address="" binding="wsHttpBinding" contract="Translation.ITranslation">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/Translation/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- Pour éviter la divulgation des informations sur les métadonnées, 
          définissez la valeur ci-dessous sur false et supprimez le point de terminaison des métadonnées ci-dessus avant le déploiement -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- Pour recevoir les détails d'exception des erreurs à des fins de débogage, 
          définissez la valeur ci-dessous sur true.  Définissez-la sur false avant le déploiement 
          pour éviter la divulgation des informations d'exception -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

我不知道问题在哪里,或者如何调试这个错误,请帮助

soap请求失败,因为假定的Web服务没有返回正确的内容类型text/xml;charset=utf-8“不是预期的类型”application/soap+xml;字符集=utf-8'。这可能有几个原因,您需要调查其中哪一个适用于您:

在PHP中创建SoapClient时指定了无效的webservice url。我看到您的url中有Service1.asmx/?wsdl,它应该是Service1.asmx?wsdl还是Service1.wsdl?总之,ASP.NET项目应该在启动项目时为您提供正确的URL。 webservice未运行,但8732端口被另一个IIS实例使用 webservice已启动但出现故障,您可以在创建SoapClient时使用trace选项来查找请求和响应。有关如何设置它的详细信息,请参阅/
请粘贴出现在web浏览器上的错误,以现在的方式读取它有点困难。它就是这样显示的:…然后请创建一个包含该内容的html文件,并将打开该html时在浏览器中看到的内容粘贴到此处。这将使帮助您阅读错误的人员更容易。好的,我有一个错误:致命错误:未捕获的SoapFault异常:[HTTP]无法处理该消息,因为内容类型为“text/xml;charset=utf-8“不是预期的类型”application/soap+xml;字符集=utf-8'。在C:\wamp\www\geogram.php:6堆栈跟踪:0[内部函数]:SoapClient->\uuu doRequest'