我正在使用Fedex webservice.他们没有提供像http://hostServer/WebserviceRoot/WebServiceName.asmx这样的Web服务URL .相反,他们提供了一个.wsdl
文件
请指导我从.wsdl
文件生成Web服务代理类并向我的项目添加Web服务引用.
我知道从wsdl
类似的生成代理
wsdl /l:cs /protocol:SOAP /o:MyProxy.cs mywsdl.wsdl
Run Code Online (Sandbox Code Playgroud)
但我想知道它的作用.它可能会创建代理类,但如何将Web服务引用添加到我的项目中?
嗨,我正在尝试使用wsdl api来计算我的网站的运费.我正在使用opencart和这个模块(http://www.opencart.com/index.php?route=extension/extension/info&extension_id=2055&filter_search=fedex&sort=e.date_modified&order=DESC).结帐时我收到此错误:
WARNING::556::There are no valid services available.
Run Code Online (Sandbox Code Playgroud)
但我尝试在联邦快递网站上的计算器上进行相同的处理,它给了我两项服务:国际优先和国际经济
这是我的调试数据:
Array
(
[WebAuthenticationDetail] => Array
(
[UserCredential] => Array
(
[Key] => REDACTED
[Password] => REDACTED
)
)
[ClientDetail] => Array
(
[AccountNumber] => REDACTED
[MeterNumber] => REDACTED
)
[TransactionDetail] => Array
(
[CustomerTransactionId] => *** Rate Request v9 using PHP ***
)
[Version] => Array
(
[ServiceId] => crs
[Major] => 9
[Intermediate] => 0
[Minor] => 0
)
[ReturnTransitAndCommit] => 1
[RequestedShipment] => Array
(
[DropoffType] => REQUEST_COURIER …
Run Code Online (Sandbox Code Playgroud) 我正在为一个或多或少不受我控制的Web服务创建一个客户端.以下是架构的简化示例:
<xs:complexType name="A">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="element1" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="element2" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="B">
<xs:complexContent>
<xs:restriction base="A">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="element2" type="xs:string" />
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)
简而言之,我们有一个包含所有元素的对象A. 该服务有几种基于A但有限制的类型,因此继承的类型通常小于基类型 - 这里以类型B为例.
在Visual Studio 2010,SoapUI等中的模式查看器中,这看起来像预期的那样.A有2个元素,B只有1个(=元素2).
通过使用svcutil我可以在我的类型A和B中获得完整的元素集,或者在使用选项时我会收到错误消息,例如:
错误:无法导入名称空间"http://tempuri.org/XMLSchema.xsd"中的"B"类型.不受支持派生的复杂类型.更改架构以便类型可以映射到数据协定类型或使用ImportXmlType或使用其他序列化程序.
隐藏继承类型中的字段/属性不是我喜欢旅行的练习/道路,但如果我无法让提供者更改WSDL,那么我似乎必须这样做.
有没有替代svcutil正确处理这个或我必须手工编码我的代理?
更新1
正如John Saunders所指出的,我没有展示svcutil的建议结果.这部分是为了保持这个职位的简短......但是这里有:
svcutil schema.xsd/importXmlTypes/datacontractonly导致:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="A", Namespace="http://tempuri.org/XMLSchema.xsd")]
public partial class A : object, System.Runtime.Serialization.IExtensibleDataObject
{
private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
private string element1Field;
private string element2Field;
public System.Runtime.Serialization.ExtensionDataObject ExtensionData
{
get
{
return …
Run Code Online (Sandbox Code Playgroud) 我正在使用php SOAPServer创建一个Web服务.我正在创建一个wsdl文件,并查找有关如何为其中一个Web服务操作设置其中一个输入参数的最小和最大字符串长度的信息.它甚至可能吗?
顺便说一句,我使用肥皂绑定样式"rpc"
我在maven项目中使用wsdl2java来生成一些工件.我没有从头开始,而是继承了我前任的工作.我有一个与我的pom文件中的标签相关的问题.
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.1.4</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdlLocation>http://localhost:8080/sunrise/sunrise?wsdl</wsdlLocation>
<wsdl>${basedir}/src/main/webapp/WEB-INF/wsdl/sunrise/sunrise.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我特别感兴趣的是内心<wsdlOptions>
.<wsdlLocation>
和之间有什么区别<wsdl>
?哪一个用于生成工件?
我使用python/suds来实现一个客户端,我在发送的SOAP头中得到错误的名称空间前缀,用于element ref=
wsdl中定义的特定参数类型.
.wsdl引用了数据类型.xsd文件,如下所示.问题在于函数GetRecordAttributes
及其第一个类型参数gbt:recordReferences
.
文件:browse2.wsdl
<xsd:schema targetNamespace="http://www.grantadesign.com/10/10/Browse" xmlns="http://www.grantadesign.com/10/10/Browse" xmlns:gbt="http://www.grantadesign.com/10/10/GrantaBaseTypes" elementFormDefault="qualified" attributeFormDefault="qualified">
<xsd:import schemaLocation="grantabasetypes2.xsd" namespace="http://www.grantadesign.com/10/10/GrantaBaseTypes"/>
<xsd:element name="GetRecordAttributes">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="gbt:recordReferences">
</xsd:element>
Run Code Online (Sandbox Code Playgroud)
引用文件:grantabasetypes2.xsd
<element name="recordReferences">
<complexType>
<sequence>
<element name="record" minOccurs="0" maxOccurs="unbounded" type="gbt:MIRecordReference"/>
</sequence>
</complexType>
</element>
Run Code Online (Sandbox Code Playgroud)
suds发送的SOAP请求:
<SOAP-ENV:Envelope xmlns:ns0="http://www.grantadesign.com/10/10/GrantaBaseTypes" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://www.grantadesign.com/10/10/Browse" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns2:GetRecordAttributes>
<ns2:recordReferences>
<ns0:record>
</ns0:record>
</ns2:recordReferences>
</ns2:GetRecordAttributes>
</ns1:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)
问题: <ns2:recordReferences>
前缀错误,应该是 <ns0:recordReferences>
因为它属于...GrantaBaseTypes
.xsd中定义的命名空间.
这适用ref=
于wsdl中定义的所有参数.如何自动修复?
注意:我通过curl手动发送xml SOAP请求,检查了服务是否接受了"good"前缀.
UPDATE
我使用SUDS源代码进行干预,并且以下经验修复强制所有带ref=
属性的元素都假定引用的命名空间(以前,它们采用模式根命名空间或其他任何东西tns
):
文件:/suds/xsd/sxbase.py
class SchemaObject(object):
....
def …
Run Code Online (Sandbox Code Playgroud) 目前我正在开发内部肥皂服务来控制一些内部流程.这通常不是那么难.然而,我尝试使用soapClient类映射功能来映射对象,而不是使用通常为非complextypes返回的stdClasses.
考虑到wsdl和源代码占用大量空间的事实,我将链接到相关文档而不是在这个问题中发送垃圾邮件.
首先,我使用Zend_Soap_Server和Zend_Soap_Server_Autodiscover为我的Soap服务和wsdl生成.
肥皂服务器代码:https: //www.dropbox.com/s/eji7l50g42m2ixl/SoapServer.txt
针对?wsdl请求的WSDL结果:https: //www.dropbox.com/s/vyxbjz7wogd8suy/wsdl.txt
soap服务发布服务类.此类包含从soap服务获取数据的方法.此方法称为getPackages.
getPackages方法构成soap服务:https: //www.dropbox.com/s/p5ddxpraju7ru6x/method_from_serviceclass.txt
getPackages方法返回一个DataObject,而DataObject又返回包含对其他数据对象的引用.这些对象作为客户端存在于两个服务器上,两端完全相同.
主要数据对象:https: //www.dropbox.com/s/qt51pw3rpq7c2ba/dataobject.txt
当连接到此服务并调用getPackages方法时,我按预期获得响应:包含vps和共享属性的stdClass.
不幸的是,在添加类映射时,结果仍然完全相同..包含vps和共享属性的stdClass.预期结果将是包含vps和共享属性的Soho_Soap_DataObject_Packages对象.
这是使用过的SoapClient代码:https: //www.dropbox.com/s/ulnni84p8dawv97/SoapClient.txt
当我通过Soap调用getPackages方法时,我得到以下内容:
$SoapClient = \Soho_Soap_Client::getInstance();
$packages = $SoapClient->getPackages();
print_r($packages);
Run Code Online (Sandbox Code Playgroud)
输出:
stdClass Object
(
[shared] => Array
(
[0] => stdClass Object
(
[id] =>
[title] =>
[pricePerPeriod] =>
[price] =>
[minRegistrationMonths] =>
[properties] =>
[options] => Array
(
)
)
)
[vps] =>
Run Code Online (Sandbox Code Playgroud)
)
但是,如果我查看响应类型,我会得到以下内容:
print_r( $SoapClient->__getTypes() );
Run Code Online (Sandbox Code Playgroud)
输出:
Array
(
[0] => Soho_Soap_DataObject_Package_Shared …
Run Code Online (Sandbox Code Playgroud) 我的要求是从Android调用Web服务并以一种很好的方式显示结果.
但是在Web服务的WSDL中我找不到SOAPAction
.WSDL看起来像这样:
<operation name="getStudentList">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
Run Code Online (Sandbox Code Playgroud)
有没有办法SOAPAction
在WSDL中找到其他一些地方?我可以调用Web服务并在没有的情况下获得结果SOAPAction
吗?
我正在使用Visual Studio(2012)创建Web服务.我不想打扰手动创建WSDL,但我真的希望能够使用XSD指定一些类型(或者全部),因为它使我能够限制某些元素(例如,需要一个元素存在).
我怎么能这样做,以便生成的自动生成的WSDL使用我的XSD(具有相同的约束)?
目的是使接口(WSDL)尽可能准确(比C#中的接口更精确).
我正在尝试从Intellij IDEA中的java类生成wsdl.
但是我收到以下错误:
Error: Could not find or load main class org.apache.axis.wsdl.Java2WSDL
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个问题吗?