首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >连接到WSDL时出现问题

连接到WSDL时出现问题
EN

Stack Overflow用户
提问于 2011-09-01 20:29:09
回答 5查看 2K关注 0票数 2

我得到了一个SDK,它使用WSDL文件连接到web服务。我在自述文件中得到了示例代码,以及如何设置该文件的逐步说明,但即使遵循所有这些说明,代码也无法编译。

说明和代码在这里。http://dl.dropbox.com/u/3425987/README.txt

WSDL文件位于此处的http://dl.dropbox.com/u/3425987/arm-inlined.wsdl

它似乎找不到ArmServiceImplService。

任何帮助我做错事的人都会非常感谢。

编辑:我做的唯一一件不遵循说明的事情是我使用的是VS2010,而不是2008。我不认为这会是问题所在,但我已经别无选择了。

EN

回答 5

Stack Overflow用户

发布于 2011-09-01 20:35:44

作为WSDL的一部分,有一个用于访问SOAP服务的位置/URL-根据WSDL,它是:

代码语言:javascript
复制
http://localhost:8080/ARM/ARM/

此位置将导致您的客户端尝试访问运行它的系统上的端口8080……除非您在那里运行SOAP服务,否则这不会起作用(连接被拒绝和/或超时)……

来自您的自述文件中的示例源代码:

代码语言:javascript
复制
// TODO: Replace with live server URL when ready
armService.Url = "http://localhost:8081/ARM/ARM/";

此注释告诉您将URL替换为实时服务器URL...

根据您的问题,我假设您没有替换URL /没有实时服务器URL?

编辑-根据OP的评论:

如果您的代码没有编译,您似乎已经跳过了自述文件中的第7点和以下说明

7) Visual Studio打开新创建的项目后,右键单击解决方案资源管理器中的SampleArmClient并选择“添加服务引用”8)在“添加服务引用”对话框中,在标记为“URL”的框中输入: a)从真实或“模拟”ARM服务到WSDL (有关启动“模拟”ARM服务的说明,请参阅第7节)。例如,如果“模拟”服务是在端口8081上启动的,则指向该服务的URL将是http://localhost:8081/ARM/ARM?WSDL.Please。请注意,在代码中使用的URL是http://:/ARM/ARM。它不包含"?WSDL“-该后缀仅用于发现web服务。b)未打包版本中wsdl所在的磁盘位置。例如,如果将发行版解压到c:/temp目录中,则URL为c:\temp\arm\src\main\resources\gov\hud\arm\wsdl\arm-inlined.wsdl.(这是包含模式的WSDL版本,以便.NET可以在没有外部模式的情况下解析引用。)

票数 1
EN

Stack Overflow用户

发布于 2011-10-18 04:36:57

最后一块拼图给你。我重新查看了我的电子邮件,看看说明中的7/8到底是什么问题,这是我向HUD报告的:

在您为Visual Studio2008提供的说明中,第8项告诉您添加服务引用。现在,一部分我做对了,另一部分我错了,因为我对.net太不熟悉了,但是,您需要将该行调整为添加一个新的Web引用(服务引用不再是一个选项)而不是服务引用,并且告诉他们将其命名为ARM非常重要

这也适用于VS2010,这也是我昨晚设法开始工作的地方。就像你知道的那样,我编辑了原始的代码帖子,删除了断开的行,所以只需对id和路径进行更改,你就可以开始工作了。我根据我从hud支持(Andrey)得到的dev url运行它,而不是试图在我的机器上运行该服务。我建议你也这样做,因为如果他们的样品这么过时,那么他们作为样品提供的服务也是如此。dev url运行得很好,尽管我也发现了一些差异。不过,它们已经被修复,所以它应该是测试xml提交文件的最佳位置。

票数 1
EN

Stack Overflow用户

发布于 2011-10-17 14:33:06

首先,我遇到了同样的问题,所以我还没有得到所有的答案。但使用VS2010时,您确实需要添加一些代码来建立连接。问题是你必须在报头中进行身份验证,而使用VS2008和更高版本,它不会这样做。

现在,还有其他问题。如果你想运行databag 4,那就是。他们给我们的代码是针对较早版本的数据库的,并且没有运行数据库4的发送/接收函数,因为它不包含这些函数的示例。我已经要求他们包括它,但谁知道这将需要多长时间。

此外,如上所述,步骤7 /8是至关重要的,并且方向是不正确的。我也已经通知了支持人员,但在我上次检查的时候,他们还没有更新注释来包括这一点。抱歉,我现在不记得细节了,但这是我在第三次或第四次阅读屏幕时捕捉到的非常简单的东西。

正如您在下面的代码中注意到的,我在正确的方向上取得了一些进展,但我不是一名.net开发人员。我是一个典型的asp人,所以目前我仍然不能通过这种方式获得完整的功能,并使用SOAP UI工具进行上传。这意味着我必须手工完成所有30个公司的工作,一次一个文件。每个文件4个。尽管如此,我在一天内就完成了工作,并为我的时间支付了很好的报酬,所以这是可以的,但我对到目前为止获得的支持感到沮丧,所以如果你从这篇文章中找到了更多,请让我知道。

代码语言:javascript
复制
    using System;
    using System.Collections.Generic;
    using System.Text;
    using ARMService.ARM;
    using System.Net;
    using System.IO;
    using System.Threading;

    namespace ARMService
    {
      public partial class api : System.Web.Services.Protocols.SoapHttpClientProtocol
    {
    //added "protected overide" to get past the pre-auth issue with VS2008 and above since I'm  running VS2010
    //Now this is in place, you will send the authentication header at the first request. 
    //Since this implementation is using the credentials from the WebClientProtocol, you will be required to set these in advance. 
    //But I guess you were doing that anyways. Furthermore, I chose to only do the pre-authentication if the PreAuthenticate 
    //property was set to true. (deactivated if statement so it will always preauth.)
    //So if you want to consume this service, this is how you would initiate it;
    //api client = new api();
    //client.PreAuthenticate = true;
    //client.Credentials = new NetworkCredential("username", "password");

    protected override System.Net.WebRequest GetWebRequest(Uri uri)
    {
        HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(uri);
        //              if (PreAuthenticate)    //removed if statement because I want all items to pre-auth
        //              {
        NetworkCredential networkCredentials = Credentials.GetCredential(uri, "Basic");
        if (networkCredentials != null)
        {
            byte[] credentialBuffer = new UTF8Encoding().GetBytes(networkCredentials.UserName + ":" + networkCredentials.Password);
            request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(credentialBuffer);
        }
        else
        {
            throw new ApplicationException("No network credentials");
        }
        //              }
        return request;
    }
}


class Program
{
    static void Main(string[] args)
    {
        ArmServiceImplService armService = new ArmServiceImplService();
        // TODO: Replace with live server URL when ready
        armService.Url = "https://HUD will give you the url/ARM/ARM/";
        armService.PreAuthenticate = true;
        NetworkCredential credentials = new NetworkCredential();
        // TODO: Replace with userid/password issued by HUD for HCS system when ready
        credentials.UserName = "yourHUDMXnumber";
        credentials.Password = "yourpassword";

        armService.Credentials = credentials;

        //These three removed per second post and fixed the last issue
        //api client = new api();
        //client.PreAuthenticate = true;
        //client.Credentials = new NetworkCredential(credentials.UserName, credentials.Password);

        //removed for now to try only postAgencyData
        //doPing(armService);
        //doGetReference(armService);
        //postSubmissionResponse submissionId = doPostSubmission(armService);

        //fixed
        postSubmissionResponse psr = AgencyData(armService);
        while (dopostAgencyDataResponse(armService, psr) != true)
        {
            // sleep for 60 seconds before checking agin.
            Thread.Sleep(60000);
        }
    }

    private static void doGetReference(ArmServiceImplService armService)
    {
        getReference getReference = new getReference();
        // TODO: Replace 80000 with your agency HCS id.
        getReference.agcHcsId = 80000;
        getReference.referenceId = 0;
        referenceItem[] referenceItems = armService.getReference(getReference);
        foreach (referenceItem referenceItem in referenceItems)
        {
            Console.WriteLine(referenceItem.id);
            Console.WriteLine(referenceItem.name);
            Console.WriteLine(referenceItem.longDesc);
            Console.WriteLine(referenceItem.shortDesc);
        }
    }

    private static void doPing(ArmServiceImplService armService)
    {
        ping pingIn = new ping();
        // TODO: Replace 80000 with your agency HCS id.
        pingIn.agcHcsId = 80000;
        string pingString = armService.ping(pingIn);
        Console.WriteLine(pingString);
    }




    private static postSubmissionResponse AgencyData(ArmServiceImplService armService)
    {
        postAgencyData AgencyData = new postAgencyData();
        submissionHeader40 header = new submissionHeader40();
        // TODO: Replace 80000 with your agency HCS id.
        header.agcHcsId = 80000;
        header.agcName = "Your Agency Name";
        // TODO: Replace 8 with your CMS vendor id issued to you by ARM Development Team.
        header.fiscalYearId = 17;
        header.reportingPeriodId = 3;
        header.cmsVendorId = yourVendorNUmber;
        AgencyData.submissionHeader40 = header;

        // TODO: Replace fake databag with valid databag of your own
        FileStream file = new FileStream("c:/Users/Public/Documents/AgencyProfileData.xml", FileMode.Open, FileAccess.Read);
        StreamReader sr = new StreamReader(file);
        string str = sr.ReadToEnd();

        System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
        AgencyData.submissionData = encoding.GetBytes(str);

        //fixed
        postSubmissionResponse psr = armService.postAgencyData(AgencyData);
        Console.WriteLine("Submitted Data returned id : " + psr.submissionId);
        return psr;
    }

    private static Boolean dopostAgencyDataResponse(ArmServiceImplService armService,
        postSubmissionResponse postAgencyDataResponse)
    {
        getSubmissionInfo getSubmissionInfo = new getSubmissionInfo();
        // TODO: Replace 80000 with your agency HCS id.
        getSubmissionInfo.agcHcsId = 80000;
        getSubmissionInfo.submissionId = postAgencyDataResponse.submissionId;
        getSubmissionInfoResponse response = armService.getSubmissionInfo(getSubmissionInfo);
        Console.WriteLine("SubmissionInfo Status Date = " + response.statusDate);
        Console.WriteLine("SubmissionInfo Status Message = " + response.statusMessage);
        // if Done or Error returned, then return true to stop polling server.
        if (response.statusMessage.Equals("DONE") || response.statusMessage.Contains("ERROR"))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7270287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档