我正在尝试在.NET 3.5中构建一个支持SOAP的C#服务 - 并显示WSDL和REST.
SOAP服务和WSDL生成很容易使用ServiceHost和BasicHttpBinding类.得到了工作,客户很高兴.
由于SOAP调用所有使用的简单参数,因此客户端开发人员为某些命令请求了REST接口.所以我改变了的ServiceHost类的WebServiceHost,根据需要添加WebInvoke和WebGet属性,增加了一个WebHttpBinding班,和宾果- REST和SOAP进行了两个工作了一个服务.很酷,改变一个界面,REST和SOAP都得到了新的东西.
但是有一个问题 - 不再生成WSDL.我无法浏览到http:// server/service?wsdl并获取WSDL文件.检查MSDN文档,这似乎是默认行为WebServiceHost.
问题:我可以覆盖此行为以便可以获取WSDL吗?没有与以前相同的URL - 它可以更改 - 但我只需要在服务中使用一些URL来为这些SOAP开发人员获取WSDL.
我无法打开元数据网址http://localhost:8082/Tasks/mex,即使我在配置文件中添加了mexHttpBinding.我可以在浏览器中查看此MEX端点吗?
配置文件如下所示:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
Run Code Online (Sandbox Code Playgroud)
问题:
我遇到了一些不同的WSDL文件,其中包含一个元素和一个具有相同名称的complexType.例如,http://soap.search.msn.com/webservices.asmx?wsdl有两个名为"SearchResponse"的实体:
在这种情况下,我无法弄清楚如何使用SoapClient()"classmaps"选项将这些实体正确映射到PHP类.
PHP手册说:
classmap选项可用于将某些WSDL类型映射到PHP类.此选项必须是一个数组,其中WSDL类型作为键,PHP类的名称作为值.
不幸的是,由于有两个具有相同密钥的WSDL类型('SearchResponse'),我无法弄清楚如何区分两个SearchResponse实体并将它们分配给相应的PHP类.
例如,以下是示例WSDL的相关代码段:
<xsd:complexType name="SearchResponse">
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="Responses" type="tns:ArrayOfSourceResponseResponses"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="SearchResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="Response" type="tns:SearchResponse"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Run Code Online (Sandbox Code Playgroud)
这里的PHP显然不起作用,因为类映射键是相同的:
<?php $server = new SoapClient("http://soap.search.msn.com/webservices.asmx?wsdl", array('classmap' => array('SearchResponse' => 'MySearchResponseElement', 'SearchResponse' => 'MySearchResponseComplexType'))); ?>
Run Code Online (Sandbox Code Playgroud)
在搜索解决方案时,我发现Java Web Services通过允许您为"Element"或"ComplexType"实体指定自定义后缀来处理此问题.
所以,现在我觉得没有办法用PHP的SoapClient做到这一点,但我很好奇是否有人可以提供任何建议.FWIW,我无法编辑远程WDSL.
有任何想法吗???
我需要在ruby中为一次调用实现一个soap服务器,并提供一个WSDL.我的计划是自己创建WSDL,并在rails服务器上提供解析xml的端点.
这是一条有效的道路吗?我看起来并且找不到关于生成WSDL的ruby中的soap服务器的其他信息.Action Web Service确实在2005年更新,而soap4r独立服务器不生成WSDL.
例如,png文件mime-type是"image/png"; 那么wsdl文件的mime类型是什么?
我可以拥有一个只使用纯XML数据而不是SOAP的WSDL吗?
如果是这样,请为我提供一个WSDL示例?
我正在尝试实现在SAP PI系统上运行的Web服务.我得到的WSDL看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="request_SO" targetNamespace="http://company.ch/orstest/jason_test" xmlns:p1="http://company.ch/orstest/jason_test" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation/>
<wsp:UsingPolicy wsdl:required="true"/>
<wsp:Policy wsu:Id="OP_request_SO"/>
<wsdl:types>
<xsd:schema targetNamespace="http://company.ch/orstest/jason_test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://company.ch/orstest/jason_test">
<xsd:element name="request" type="request"/>
<xsd:element name="response" type="response"/>
<xsd:complexType name="request">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">a8b7948ac2e211e2b2380000001f0d6a</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="body" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="response">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">bf49af09c36c11e299790000001f0d6a</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="body" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="request">
<wsdl:documentation/>
<wsdl:part name="request" element="p1:request"/>
</wsdl:message>
<wsdl:message name="response">
<wsdl:documentation/>
<wsdl:part name="response" element="p1:response"/>
</wsdl:message>
<wsdl:portType name="request_SO">
<wsdl:documentation/>
<wsdl:operation name="request_SO">
<wsdl:documentation/>
<wsp:Policy>
<wsp:PolicyReference URI="#OP_request_SO"/>
</wsp:Policy>
<wsdl:input message="p1:request"/> …Run Code Online (Sandbox Code Playgroud) 我在创建Java客户端并将其连接到正在运行的Web Service时遇到问题.
我使用以下代码:
Service myService = null;
URL wsdlLocation = new URL("http://myservice?wsdl");
QName serviceName = new QName(wsdlLocation, "MyService");
Service myService = new Service(wsdlLocation, serviceName);
Run Code Online (Sandbox Code Playgroud)
使用以下命令创建Service类的位置:
wsimport -d gen -keep http://myservice?wsdl
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用Apache cxf 2.4的wsdl2java生成的客户端,但得到了相同的结果.
(我已经在我使用原始代码的代码中更改了此帖子的WSDL位置和服务类名称.)
但是当我使用新的Service()命令创建服务时,我在appserver上调用Web Service时遇到异常.但是:我用SOAP UI测试了wsdl位置,它运行得很好.此外,我使用Soap UI创建了一个模拟服务,我的Java客户端可以连接到它,调用它并获得结果.当我想要调用在appserver上运行的Web服务时,会出现问题.
堆栈跟踪:
javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:98)
at javax.xml.ws.Service.<init>(Service.java:76)
at MyService.<init>(MyService.java:42)
at mypackage.createService(AClass.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:100)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:199)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
... 12 more …Run Code Online (Sandbox Code Playgroud) @XmlElement带字符串长度限制的JAXB (生成的XSD简单类型)
我使用Java生成SOAP Web服务.因此,这是代码第一种方法
在Java中我有一个String字段,我希望其长度限制为50个字符.
@XmlRootElement
public class ContactTO {
private String comment;
@XmlElement
public void setComment(String comment) {
this.comment = comment;
}
}
public class ContactWebService implements ContactServiceIf {
@Override
public ContactTO createContact(@WebParam(name = "newContact") ContactTO newContact)
...
Run Code Online (Sandbox Code Playgroud)
显示:
<xs:complexType name="contactTO">
<xs:sequence>
<xs:element minOccurs="0" name="comment" type="xs:string" />
Run Code Online (Sandbox Code Playgroud)
如何将注释元素限制为50?
我想要这样的东西:
<xs:simpleType name="LimitedString">
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
Run Code Online (Sandbox Code Playgroud)
或类似的东西:
<xs:simpleType name="fourCharAlphaString">
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z]{4}"/>
</xs:restriction>
</xs:simpleType>
Run Code Online (Sandbox Code Playgroud)
但我无法手动编辑wsdl中的内联(生成)xsd.
非常感谢你.
(注:http: …
我在eclipse中使用Tomcat 7服务器和Axis 2 1.7运行时.
我有一个在Axis 2中生成的WSDL文件.
因此,请使用Topdown方法生成Web服务类(骨架).我在服务器运行时选择了配置为Axis.当尝试单击完成时,它显示以下错误:" 在WSDL的代码生成期间发生异常:java.lang.NoClassDefFoundError:org/apache/ws/commons/schema/utils/NamespacePrefixList "
我认为这是一个罐子小姐,所以我首先包括XmlSchema-1.4.2.jar错误尚未解决.所以我删除了那个jar并尝试使用从java2s下载的最新jar(xmlschema-core-2.0.1.jar).我还有同样的问题.
请帮我解决这个问题.
尝试在eclipse中从WSDl创建客户端时,同样的问题也会持续存在.
请帮我用步骤来解决这个问题.谢谢