C# PHP对.NET soap Web服务的调用

C# PHP对.NET soap Web服务的调用,c#,php,wcf,web-services,soap,C#,Php,Wcf,Web Services,Soap,我知道有很多关于php调用soap Web服务的问题和教程,但我不明白它对我来说是如何工作的 我用一些非常简单的方法制作了.NET Windows通信基础WebService。 我使用了本教程: 我想从PHP调用这个方法。我用一行代码制作了一个php文档。我可以从我的服务中获取函数列表,并且可以向Web服务发送一些数据。但是,我的webservice的方法中的参数是空的,但仍然会触发断点,返回值将返回到我的PHP 我想我错过了很多关于标题、参数、安全性和类似的东西。有人能告诉我我错过了什么,我应

我知道有很多关于php调用soap Web服务的问题和教程,但我不明白它对我来说是如何工作的

我用一些非常简单的方法制作了.NET Windows通信基础WebService。

我使用了本教程:

我想从PHP调用这个方法。我用一行代码制作了一个php文档。我可以从我的服务中获取函数列表,并且可以向Web服务发送一些数据。但是,我的webservice的方法中的参数是空的,但仍然会触发断点,返回值将返回到我的PHP

我想我错过了很多关于标题、参数、安全性和类似的东西。有人能告诉我我错过了什么,我应该怎么做才能得到它吗

我的服务合同:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace Service
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "ICalculator" in both code and config file together.
    [ServiceContract]
    public interface ICalculator
    {

        [OperationContract]
      double AddNumbers(double number1, double number2);

        [OperationContract]
      double SubstractNumbers(double number1, double number2);

        [OperationContract]
      double MultiplyNumbers(double number1, double number2);

        [OperationContract]
      double DivisionNumbers(double number1, double number2);
    }
}
我的服务:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace Service
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Calculator" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Calculator.svc or Calculator.svc.cs at the Solution Explorer and start debugging.
    public class Calculator : ICalculator
    {
        public double AddNumbers(double number1, double number2)
        {
            double result = number1 + number2;
            return result;
        }

        public double SubstractNumbers(double number1, double number2)
        {
            double result = number1 - number2;
            return result;
        }

        public double MultiplyNumbers(double number1, double number2)
        {
            double result = number1 * number2;
            return result;
        }

        public double DivisionNumbers(double number1, double number2)
        {
            double result = number1 / number2;
            return result;
        }  
    }
}
Web.Config

<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="Service.Calculator">
        <endpoint address="" contract="Service.ICalculator" binding="basicHttpBinding"/>
        <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
      </service>
    </services>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

PHP


您的WebConfig文件指定了HTTPS协议:

$client = new SoapClient('http://localhost:1336/Calculator.svc?wsdl');
尝试更改一个或另一个以使它们匹配。
首选HTTP进行测试,以避免潜在的证书问题


另外,
AddNumbers
方法预期会收到两个参数

print_r($client->AddNumbers());
PHP调用中没有提供这些内容


我将https更改为http,但仍然无法工作。是的,我在PHP中遇到一个错误。它是荷兰语的,所以我将尝试翻译它:发生了一个错误:试图发送消息时格式化程序出现异常。反序列化请求方法AddNumbers的消息时出错。应为命名空间的最后一个元素体:没错。但有两个理由,它仍然不起作用。同样的错误。
$client = new SoapClient('http://localhost:1336/Calculator.svc?wsdl');
double AddNumbers(double number1, double number2);
print_r($client->AddNumbers());