在另一类中调用Java类方法



嗨,我在Java类以下是从Java发送传真

package oracle.apps.print;
import com.softlinx.replixfax.*;
import javax.xml.ws.*;
import org.apache.commons.codec.binary.Base64;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.io.File;
public class Fax {
    public void SendFax(String Filepath, String faxno) {
        try {

            ReplixFaxService service = new ReplixFaxService();
            ReplixFaxPort port = service.getReplixFaxPort();
            ((BindingProvider)port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "admin");
            //            ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"https://api.rpxfax.com/softlinx/replixfax/wsapi");
            ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                                                            "https://api.rpxtest.com:9999/softlinx/replixfax/wsapi");

            Authentication auth = new Authentication();
            auth.setLogin("user");
            String password = "pwd";
            auth.setPassword(org.apache.commons.codec.binary.Base64.encodeBase64String(password.getBytes()));
            auth.setRealm("MTBC");
            auth.setPasswordSecurity("base64");

            SendFaxInput sendFaxInput = new SendFaxInput();
            sendFaxInput.setAuthentication(auth);
            FaxRecipient recipient = new FaxRecipient();
            recipient.setFaxNumber(faxno.toString());
            Attachment attachment = new Attachment();
            File f = new File(Filepath.toString());
            attachment.setFileName(f.getName());
            Path path = Paths.get(Filepath.toString());
            byte[] data = Files.readAllBytes(path);
            attachment.setAttachmentContent(data);
            sendFaxInput.getFaxRecipient().add(recipient);
            sendFaxInput.getAttachment().add(attachment);
            SendFaxOutput result = port.sendFax(sendFaxInput);
            System.out.println("Status Code= " + result.getRequestStatus().getStatusCode());
            if (result.getFaxInfo() != null) {
                System.out.println("Fax ID = " + result.getFaxInfo().get(0).getFaxId());
            }

        } catch (Exception ex) {
            System.out.println("Exception: " + ex.getMessage());
        }
    }
}

我正在像这样编译此类

javac -cp .;./commons-codec-1.10.jar Fax.java

然而,在编译时间

的两个类都没有错误的编译

当我在其他类(xxemail)中调用方法 Fax

package oracle.apps.print;

public class XXEmail implements JavaConcurrentProgram {
    public static void main(String[] args) {
        try {
            Fax mtbcfax = new Fax();
            mtbcfax.SendFax("E:\csv_svb\3010218.pdf", "173224xxxx");
            out.writeln("Fax Sent Successfully");
        } catch (Exception i) {
            log.writeln("Error while Sending Fax " + i.getMessage(), LogFile.STATEMENT);
        } finally {
            log.writeln("Error while Sending Fax ");
        }
    }
}

它总是最终阻止显示任何错误

我该如何调用此方法,以便使用成功代码或异常

返回

尝试:评论sendfax函数中的所有行,仅添加一个日志:

public void SendFax(String Filepath, String faxno) {
   out.writeln("No problem here");
}

现在启动程序,看看该函数是否正确调用。如果正确地调用了它,那么您发送的参数可能是错误的。

相关内容

  • 没有找到相关文章

最新更新