为什么这个WSDL文件在VS2008中生成一个空的服务代理?
如果查看生成的Reference.cs文件,则为空.有任何想法吗?
我有一个带有方法签名的Web服务,如下所示:
public RetType doIt(String description){
return null;
}
Run Code Online (Sandbox Code Playgroud)
在生成wsdl之后,我看到(在wsdl中)方法doIt有参数名称arg0.在代码优先方法中是否有一种方法可以像在Java类方法签名中那样在wsdl中指定参数名称?
我尝试使用PHP使用一个简单的Web服务,但是我得到以下错误消息(因为在我看来)说SOAP URL无法打开,但在浏览器中它确实可以正常工作(http://www.webservicex) .NET/uklocation.asmx?WSDL).
任何想法我的错误在哪里?
错误消息:
警告:SoapClient :: SoapClient(http://www.webservicex.net/uklocation.asmx?WSDL)[soapclient.soapclient]:无法打开流:连接在/ home/sia-deutschland_de/www/tests/test中超时第14行的.php
警告:SoapClient :: SoapClient()[soapclient.soapclient]:I/O警告:无法在/ home/sia-deutschland_de/www中加载外部实体"http://www.webservicex.net/uklocation.asmx?WSDL"第14行的/tests/test.php异常错误!
SOAP-ERROR:解析WSDL:无法从'http://www.webservicex.net/uklocation.asmx?WSDL'加载:无法加载外部实体"http://www.webservicex.net/uklocation.asmx? WSDL"
我的代码:
<?php
// include the SOAP classes
require_once('nusoap.php');
try {
$options = array(
'soap_version'=>SOAP_1_2,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE
);
$client = new SoapClient("http://www.webservicex.net/uklocation.asmx?WSDL", $options);
// Note where 'Get' and 'request' tags are in the XML
//$client = new soapclient("http://www.webservicex.net/uklocation.asmx?WSDL", $options);
$err = $client->getError();
if ($err) {
// Display the error
echo 'client construction error: ' . $err ;
} else {
$answer = $client->call(’GetUKLocationByCounty’,
array(
'Country'=>'London')); …Run Code Online (Sandbox Code Playgroud) 我正在尝试在另一个环境中模拟现有的Web服务以进行测试,并遇到了障碍.
我正在尝试在WCF中创建这个Mock服务
我正在嘲笑的服务(在WCF中没有开发)有一个具有这种类型定义的实体:
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="dog" nillable="true" type="xs:string"/>
</xs:sequence>
Run Code Online (Sandbox Code Playgroud)
注意maxOccurs ="unbounded"消息本身看起来像这样:
<dog>1</dog>
<dog>2</dog>
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何定义我的DataContract来处理这个问题.我假设只使用如下数组类型:
[DataContract]
public class P56040Input
{
[DataMember]
public string[] dog { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
会对应,但它会对新类型(arrayofstring)做出意想不到的事情:
<xs:sequence>
<xs:element xmlns:q1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="dog" nillable="true" type="q1:ArrayOfstring"/>
</xs:sequence>
Run Code Online (Sandbox Code Playgroud)
这甚至可以在WCF中进行模拟吗?
是否有GUI工具可以显示有关WSDL文件和XSD文件的详细信息?
也许WSDL编辑器也是一种选择.我的需求主要是检查我必须调用服务的结构和选项.最好是比仅仅读取XML文件本身更具图形性.
我尝试过Eclipse WSDL编辑器,它非常有用,但是我遇到了麻烦.那么,是否有类似的替代方案?(否则我需要修复Eclipse工具......)
我正在使用网络服务(由于保密,我无法透露姓名).在获取wsdl页面之前,Web服务要求我使用用户名和密码登录.例如,如果我在Web服务器中输入服务URL,则会提示我输入登录信息.
所以,我假设需要首先验证自己,然后使用wsdl.
但是,我写了一些测试代码,这些代码消耗了w3schools Celsius到Fahrenheit服务,它不需要身份验证并且工作正常.
<!--- soap request in xml --->
<cfsavecontent variable="soap">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://www.w3schools.com/webservices/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<SOAP-ENV:Body>
<tns:CelsiusToFahrenheit xmlns:tns="http://www.w3schools.com/webservices/">
<tns:Celsius>34</tns:Celsius>
</tns:CelsiusToFahrenheit>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</cfsavecontent>
<!---Sending a post request accessing the defined SOAPAction CelsiusToFahrenheit--->
<cfhttp url="http://www.w3schools.com/webservices/tempconvert.asmx" method="post" result="httpresponse">
<cfhttpparam type="header" name="content-type" value="text/xml">
<cfhttpparam type="header" name="SOAPAction" value="""http://www.w3schools.com/webservices/CelsiusToFahrenheit""">
<cfhttpparam type="header" name="content-length" value="#len(soap)#">
<cfhttpparam type="header" name="charset" value="utf-8">
<cfhttpparam type="xml" name="message" value="#trim(soap)#">
</cfhttp>
<!---Output the result if http status is 200 …Run Code Online (Sandbox Code Playgroud) 我有以下用于发出SOAP请求的Java客户端:
package com.example.petstore.test;
import java.util.GregorianCalendar;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import com.example.petstore.schema.ProcessUpdateResponse;
import com.example.petstore.schema.SyncProcessDAO;
public class TestUtility {
public static void main(String[] args) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
// Use the URL defined in the soap address portion of the WSDL
factory.setAddress("http://192.168.1.4:8080/MySyncService/services/SyncProcessDAOPort");
// Utilize the class which was auto-generated by Apache CXF wsdl2java
factory.setServiceClass(SyncProcessDAO.class);
Object client = factory.create();
try {
// Call the Web Service to perform an operation
GregorianCalendar gregory = new GregorianCalendar();
XMLGregorianCalendar xmlgregory …Run Code Online (Sandbox Code Playgroud) 有一个简单的WCF Web服务。对Web服务的所有外部请求都必须经过身份验证。
Web服务的合同:
namespace SimpleCustomService
{
[ServiceContract]
public interface UsrIService
{
[OperationContract]
string SayHello();
}
}
Run Code Online (Sandbox Code Playgroud)
Web服务的实现:
namespace SimpleCustomService
{
public class UsrService : UsrIService
{
public string SayHello()
{
return "Hello";
}
}
}
Run Code Online (Sandbox Code Playgroud)
通过使用该wsdl.exe实用程序,我生成了代理类来调用Web服务的方法。
生成的代码如下:
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;
//
// This source code was auto-generated by wsdl, Version=4.6.1055.0.
//
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="BasicHttpBinding_UsrIService", Namespace="http://tempuri.org/")]
public partial class UsrService : System.Web.Services.Protocols.SoapHttpClientProtocol {
private System.Threading.SendOrPostCallback SayHelloOperationCompleted; …Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用欧盟的网站来验证TIN号码(Europa TIN验证网站 - 页面底部有一个WSDL)
我遇到的问题是,当我尝试创建一个新的SoapClient时,该函数在构建客户端时会立即失败.起初我遇到了"无法加载外部实体",我认为这是因为WSDL具有安全连接.搜索后我发现一些答案说这个问题可能与证书过时和最新版本的PHP抛出错误有关,所以我禁用了证书验证:
// Stream context due to certificate problems
$streamContext = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
));
Run Code Online (Sandbox Code Playgroud)
但现在我又收到了另一个错误:"无法打开流:HTTP请求失败!HTTP/1.1 502 Bad Gateway".有关如何解决这个问题的任何想法?如果我从链接中删除"https://",我会得到与之前"无法加载外部实体"消息相同的结果.
现在这里是真正的大脑选择器.如果我尝试使用chrome的扩展"Boomerang"来测试WSDL上的SOAP调用,它的工作非常完美,所以我不知道这里有什么问题......任何人都可以通过尝试在PHP文件中进行soap调用来轻松尝试.
这是完整的代码:
public static function validateTIN($tin) {
// Stream context due to certificate problems
$streamContext = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
));
// Create our soap client
$client = new SoapClient('https://ec.europa.eu/taxation_customs/tin/checkTinService.wsdl', array(
'exceptions' => 0,
'trace' => …Run Code Online (Sandbox Code Playgroud) wsdl ×10
web-services ×6
java ×3
soap ×3
c# ×2
php ×2
wcf ×2
xsd ×2
.net ×1
coldfusion ×1
jax-ws ×1
linux ×1
nusoap ×1
ws-security ×1
xml ×1