我想在VS Pro 2012(VB.NET)中构建一个应用程序,该应用程序将调用RoyalMail的MailMark WSDL,该方法具有期望单个参数(请求)的RetrieveActiveSupplyChains等方法, 。在vb.net中使用第三方web服务
我已经使用SvcUtil工具与/ L:VB切换到下载WSDL,并在我的项目中引用它,我可以看到,一旦我做了
Dim client As PosterUploadClient = New PosterUploadClient()
现在打字的客户端暴露的方法。提出了我期望看到的所有方法,并且我可以通过身份验证并在执行client.open()时查看状态更改,但我无法弄清楚如何提供实际方法所需的参数。根据他们的文档,RetrieveActiveSupplyChains不需要参数,但他们已经提供了一个xml示例的请求结构,所以我的假设是我需要将此构造为具有适当值的xml并将其作为“请求”发送出去?
听起来不错?我知道这可能是一个网络程序员的肉和蔬菜,但不是我以前尝试过的东西。他们提供作为例子的XML看起来像如下:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">http://rm-manifest.com/2014/01/service/IPosterUpload/RetrieveAllActiveSupplyChains</a:Action>
<a:MessageID>urn:uuid:ab5e32a3-812e-4d91-97a8-de00a08874e9</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://rm-manifest.com/PosterUpload2/PosterUpload.svc/service</a:To>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2014-10-03T14:32:58.480Z</u:Created>
<u:Expires>2014-10-03T14:37:58.480Z</u:Expires>
</u:Timestamp>
<o:UsernameToken u:Id="uuid-dfaaf0b0-3823-4f75-b607-33f7434295dc-1">
<o:Username>NetworkAccess</o:Username>
<o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">p1</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<RetrieveAllActiveSupplyChains xmlns="http://rm-manifest.com/2014/01/service">
<request xmlns:b="http://rm-manifest.com/2014/01/messages" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
</RetrieveAllActiveSupplyChains>
</s:Body>
</s:Envelope>
但我仍然不知道它是如何需要提交,当然如果我读了一个样本用新的XmlTextReader它不喜欢它与以下错误消息
Value of type 'System.Xml.XmlTextReader' cannot be converted to 'MM_TEST.Mosaic.EIB.PosterUploadService.Core.Messages.RetrieveActiveSupplyChainsRequest'
我的假设是WSDL,就无需在我的代码,但不知道实际创建一个“新的HttpRequest”。我已经做了很多谷歌上搜索,但没有得到任何东西,很是这样的
的WSDL这里如果这能帮助的: https://customertest.rm-manifest.com/PosterUpload/PosterUpload.svc
感谢您的回复,所以对于需要我发送参数(如SupplyChainID)的方法,那么语法是什么?虽然如果我只是调用它自己的方法它说参数没有指定'公共函数RetrieveActiveSupplyChains(请求为Mosaic.EIB.PosterUploadService.Core.Messages.RetrieveActiveSupplyChainsRequest)参数'请求'作为Mosaic.EIB.PosterUploadService.Core.Messages .RetrieveActiveSupplyChainsResponse' – Colster
只要在调用方法时传递id(我认为是一个整数)作为参数。并确保为所有参数提供参数值。错误消息表示您忘记了传递参数。如果参数需要一个对象,创建一个该类型的对象并设置它的值 –
然后我得到'Integer'类型的值不能被转换为'MM_TEST.Mosaic.EIB.PosterUploadService.Core.Messages.RetrieveActiveSupplyChainsRequest'。我认为这是我的问题的关键,我知道每个方法“应该”需要什么参数以及什么格式(字符串,int等),但所有方法只接受一个“请求”参数 – Colster