1

我有一个使用 NuSOAP 库构建的 PHP Web 服务。我已经调整了 Web 服务以与 Windows Phone 一起使用,一切似乎都很好。

问题是当我收到回复时,我收到了 CommunicationException。我认为那是无法识别 ?wsdl 的端点的 url。

我搜索了有关它的信息,但找不到任何解决方法。

我的代码如下:

       private void button1_Click(object sender, RoutedEventArgs e)
       {
        var test = new TS.TestWSDLPortTypeClient();
        test.sumarCompleted += test_sumarCompleted;
        test.sumarAsync(3, 4);
       }

      void test_sumarCompleted(object sender, TS.sumarCompletedEventArgs e)
      {
      MessageBox.Show(e.Result.ToString();
      }

还有我的 .ClientConfig

<configuration>
             <system.serviceModel>
                <bindings>
                   <basicHttpBinding>
                    <binding name="TestWSDLBinding" maxBufferSize="2147483647"                                      maxReceivedMessageSize="2147483647">
                     <security mode="None" />
                 </binding>
             </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://192.168.1.38/ws_test.php" binding="basicHttpBinding"
                bindingConfiguration="TestWSDLBinding" contract="TestWSDL.TestWSDLPortType"
                name="TestWSDLPort" />
              </client>
              </system.serviceModel>
               </configuration>

我也测试过:

<endpoint address="http://192.168.1.38/ws_test.php?wsdl"...

我也测试了一个域名,ip:127.0.0.1,其他端口等。

PHP代码是:

#Declaración del servidor nusoap
$server = new soap_server();
$server->configureWSDL("TestWSDL","urn:TestWSDL", "http://libreriacloud.sytes.net/ws_monster/ws_test.php?wsdl");
$server->soap_defencoding = 'UTF-8'; 

#Registro de la Funcion Sumar
$server->register(
    'sumar',
    array(
        'x' => 'xsd:int',
        'y' => 'xsd:int'
        ),
    array('return' => 'xsd:int'),
    'urn:TestWSDL',
    'urn:TestWSDL/sumar',
    'document',
    'literal',
    'Suma dos datos'
);

function sumar($x, $y)
{
    return $x+$y;
}

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA); 

WSDL 网址是: http: //libreriacloud.sytes.net/ws_monster/ws_test.php

4

2 回答 2

1

我解决了我的问题。而不是'document'到''已经把'document',因为他在svc中见过,我发疯了寻找答案到底去试错了。

服务器编码解决方案:

#Declaración del servidor nusoap
$server = new soap_server();
$server->configureWSDL("TestWSDL","urn:TestWSDL", "http://libreriacloud.sytes.net/ws_monster/ws_test.php?wsdl");
$server->soap_defencoding = 'UTF-8'; 

#Registro de la Funcion Sumar
$server->register(
    'sumar',
    array(
        'x' => 'xsd:int',
        'y' => 'xsd:int'
        ),
    array('return' => 'xsd:int'),
    'urn:TestWSDL',
    'urn:TestWSDL/sumar',
    '',
    'literal',
    'Suma dos datos'
);

function sumar($x, $y)
{
    return $x+$y;
}

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA); 

是一样的,但是下

'urn:TestWSDL/sumar',

我放单引号

于 2011-11-08T19:50:36.767 回答
0

看来您对网络服务有一些控制权。如果是这样,我会远离 SOAP,而使用更简单的技术堆栈,例如带有 JSON 的 REST。为什么?因为 WCF 功能强大但难以调试/设置等。

有很多很好的库可以在 .NET 上使用 JSON:http://json.codeplex.com/如果 您需要的不仅仅是 WebClient/WebRequest,还有 REST : http ://restsharp.org/

抱歉,如果这不是您期望的答案,但我与 WCF 进行了很多工作以了解何时不使用它。

于 2011-11-07T22:54:49.107 回答